【发布时间】:2019-09-25 12:56:11
【问题描述】:
我通过在我的 linux 操作系统的 /etc/hosts 中映射本地 IP 域,在我的 Angular 应用程序中实现了 express-simple-cdn。使用 chrome lighthouse 性能从 50 提高到 80。但是,我在浏览器上点击应用程序 url 时得到了这个-
我的代码是 -
Angular 中的 app.js(当我通过 app.js 文件运行我的 Angular 应用程序时)
var CDN = "http://myproject.test"
app.locals.CDN = function(path, type, classes, alt) {
if(type == 'js') {
return "<script src='"+CDN+path+"' type='text/javascript'></script>";
} else if (type == 'css') {
return "<link rel='stylesheet' type='text/css' href='"+CDN+path+"'/>";
} else if (type == 'img') {
return "<img class='"+classes+"' src='"+CDN+path+"' alt='"+alt+"' />";
} else {
return "";
}
};
module.exports = app;
index.html
<img class="img-responsive" style = "visibility:hidden" src="http://myproject.test/../../assets/images/insta.BIZ.banner.d.jpg.png" alt="my picture" />
即使我将路径更改为 -
<img class="img-responsive" style = "visibility:hidden" src="http://myproject.test/assets/images/insta.BIZ.banner.d.jpg.png" alt="my picture" />
我仍然得到同样的错误。是否因为 Lighthouse 中的错误而导致我读错了?
【问题讨论】:
-
"使用 chrome lighthouse 性能从 50 提升到 80。"这真的没有任何意义。
标签: express http-status-code-404 cdn