Refused to load the image ‘blob:…’ because it violates the following Content Security Policy

This is the fix for both image and base64. Need to add img-src ‘self’ blob: data:; As follow: <meta http-equiv=”Content-Security-Policy” content=” worker-src blob:; child-src blob: gap:; img-src ‘self’ blob: data:; default-src * ‘self’ ‘unsafe-inline’ ‘unsafe-eval’ data: gap: content:”>

The Chrome extension popup is not working, click events are not handled

Your code is not working because it violates the default Content Security Policy. I’ve created a screencast of one minute to show what’s wrong: First, I’ve shown how to debug the problem. Right-click on your popup button, and click on “Inspect popup”. After doing that, you will see the following error message: Refused to execute … Read more

Content security policy for frame. frame-src vs frame-ancestors

default-src, frame-ancestors, and frame-src are all part of the Content-Security-Policy response header. frame-src Restricts what domains and page can load in an iframe. The HTTP Content-Security-Policy (CSP) frame-src directive specifies valid sources for nested browsing contexts loading using elements such as <frame> and <iframe>. For example: If the website at https://example.com has a response header … Read more

Chrome version 18+: How to allow inline scripting with a Content Security Policy?

For recent versions of Chrome (46+), the previously accepted answer is no longer true. unsafe-inline still has no effect (in the manifest and in meta header tags), but per the documentation, you can use the technique described here to relax the restriction. Hash usage for <script> elements The script-src directive lets developers whitelist a particular … Read more

Make Angular working with restrictive Content Security Policy (CSP)

Edited answer for @angular/cli>=8.2 From this Github thread, one can use the index property in angular.json to control the generation of the application’s HTML index: build: { … “configurations”: { “production”: { “index”: { “input”: “src/index.production.html”, “output”: “index.html” }, … } } } Original answer I’ve found a way to have restrictive CSP on my … Read more

Script causes “Refused to execute inline script: Either the ‘unsafe-inline’ keyword, a hash… or a nonce is required to enable inline execution”

The best way to fix this would be to take that $.ajax(…) call out of the document and move it into an external file called ajax-call.js, and then do the following: <script src=”ajax-call.js”></script> The reason that’s better is, if you’re already going to the effort of setting a CSP policy for your document, then you … Read more

Google Adwords CSP (content security policy) img-src

Unfortunately, there aren’t many ways around this. Resources require either whitelisting (in the case of remote resources, like this one) or inlining tricks (i.e. nonce or sha256-…) when CSP is active. At the end of the day, though, CSP can probably still make your site safer and protect most resources. Depending on what you are … Read more