【问题标题】:Performance has improved by using express-simple-cdn but get 404-not-found error in console使用 express-simple-cdn 提高了性能,但在控制台中出现 404-not-found 错误
【发布时间】: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


【解决方案1】:

我需要在 html 中用单引号将值输入为 -

<img class="img-responsive" style = "visibility:hidden" src="'http://myproject.test/assets/images/insta.BIZ.banner.d.jpg.png'" alt="my picture" />

【讨论】:

    猜你喜欢
    • 2021-03-29
    • 2017-09-03
    • 2016-10-05
    • 1970-01-01
    • 2017-04-17
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 2012-09-27
    相关资源
    最近更新 更多