Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

See "Cannot /GET" and error about favicon not loading due to default-src "none" and no img-src explicitly set #32

Open
bruggineer opened this issue Oct 30, 2020 · 3 comments

Comments

@bruggineer
Copy link

Hello wise coder,

The error is:
Failed to load resource: the server responded with a status of 404 (Not Found) localhost/:1 Refused to load the image 'http://localhost:3002/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

In searching for and trying out solutions, I came across one recommending your module so I installed it, set it up, but am still getting that error. I've also tried many other suggestions from across the nets.
Am pretty sure this is just "MY" issue, being a noob and all, can you please advise?
My server.js followed by index.html:
Screen Shot 2020-10-30 at 11 52 59 AM
Screen Shot 2020-10-30 at 11 47 12 AM

@frux
Copy link
Owner

frux commented Oct 30, 2020

Hi! I think the reason you get this error is the order of middlewares. Favicon is served by express.static but express-csp-header is placed after it. Try to place express-csp-header just before it.

@bruggineer
Copy link
Author

Hello and thanks for the response. I have moved express-csp-header as you suggested but am still getting the same message:
Screen Shot 2020-11-05 at 1 02 43 PM

I doubt the issue is with your code, have backed it out and will tackle PWA later, and yes, I'm still getting the same error and have exhausted ideas gleaned from careful Googling.

@frux
Copy link
Owner

frux commented Mar 20, 2021

Can you show me headers which you get when request that image. Do they even contain Content-Security-Policy header?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants