通过使用express-simple-cdn可以提高性能,但在控制台中出现404-not-found错误

问题描述 投票:0回答:1

我通过在Linux OS的/ etc / hosts中映射本地ip域,在我的角度应用程序中实现了express-simple-cdn。使用铬灯塔的性能从50提高到80。但是,我在浏览器上点击应用程序URL时得到了这一点

my project-error

我的代码是-

app.js in angular(当我通过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中的错误而导致我得到了错误的阅读?

我通过在Linux OS的/ etc / hosts中映射本地ip域,在我的角度应用程序中实现了express-simple-cdn。使用铬灯塔的性能从50提高到80。但是,我得到...

express http-status-code-404 cdn
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.