问题
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