Performance has improved by using express-simple-cdn but get 404-not-found error in console

谁都会走 提交于 2019-12-11 06:24:32

问题


I have implemented express-simple-cdn in my angular app by mapping the local ip domain in /etc/hosts of my linux OS. The performance has improved from 50 to 80 using chrome lighthouse . However, I get this on hitting the application url on browser-

My code is -

app.js in angular (as I run my angular app through app.js file)

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" />

even when I change the path to -

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

I still get the same error .Also is it that I am getting false reading because of the error in Lighthouse ?


回答1:


I needed to input the value in html in single quotations as -

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


来源:https://stackoverflow.com/questions/58079941/performance-has-improved-by-using-express-simple-cdn-but-get-404-not-found-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!