简体   繁体   中英

Content Security Policy preventing images from loading

I have an express app which is loading some external assets, but they're getting blocked by CSP. I've never had this issue before, but this is the first time im using passport.js and helmet.js within an app so maybe this has something to do with their configuration?

Refused to load the image 'https://fake-url.com' because it violates the following Content Security Policy directive: "img-src 'self' data:".

I've tried adding a meta tag to allow images from external sources but this seems to have no effect. Any help would be appreciated.

You have

content="default-src 'none'

This prevents loading resources from any source. Remove it.

Then change it to:

default-src 'self' fake-url.com';

More info bout the HTTP Content-Security-Policy response header below:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy

https://content-security-policy.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM