ResourceOverride icon indicating copy to clipboard operation
ResourceOverride copied to clipboard

Refused to load the script because it violates the following Content Security Policy directive

Open Lyfhael opened this issue 2 years ago • 3 comments

Hi,

I try to override a .js file from a website, but when I do the file doesn't load and I get the following error message :

website.com/:1 Refused to load the script 'data:text/javascript;charset=UTF-8;base64,...'
because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' 
https://*.website.com https://website.com https://*.website1.com https://website.com https://cdn.website.net 
https://cdnjs.cloudflare.com https://www.google.com https://www.gstatic.com https://www.googletagmanager.com 
https://www.google-analytics.com https://*.website2.com https://*.website2.net". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

Is there a way to fix that ?

Lyfhael avatar Sep 18 '21 22:09 Lyfhael

Same issue

immrakpk avatar Nov 07 '21 00:11 immrakpk

Could maybe try using a header rule to delete the "Content-Security-Policy" header. Not sure if that will work.

kylepaulsen avatar Nov 07 '21 05:11 kylepaulsen

I end up putting nginx at front of nuxt and use nginx header in location area as follow (and it works)

add_header Content-Security-Policy " default-src *.mywebsite.com *.gstatic.com *.googleapis.com *.fontawesome.com script-src 'self' 'unsafe-inline' 'unsafe-eval' *.gstatic.com; font-src 'self' data: blob: *.gstatic.com *.googleapis.com *.google-analytics.com *.cloudflare.com *.fontawesome.com; img-src 'self' data: blob: *.mywebsite.com *.gstatic.com *.googleapis.com; media-src 'self' data: blob: *.mywebsite.com *.gstatic.com *.googleapis.com; object-src 'self'; connect-src 'self' *.mywebsite.com;";

immrakpk avatar Nov 09 '21 20:11 immrakpk