Tuesday, December 28, 2021

[FIXED] Content Security Policy directive: "script-src 'none' Violation Error

Issue

I have just installed MAMP and created 2 files in the htdocs folder:

  • index.html

    <!doctype html>
    <html>
        <body>Test Page</body>
        <script src="script.js"></script>
    </html>
    
  • script.js

    console.log("works");
    

MAMP is configured to the following ports:

  • Apache Port: 8888
  • Nginx port: 7888
  • MySQL port: 8889

Opening localhost:8888 gives the following error in console:

Refused to load the script 'http://localhost:8888/script.js' because it violates the following Content Security Policy directive: "script-src 'none'".

I have never encountered CSP before, so this has left me bewildered. What is causing this issue?


Solution

Turns out the cause of this problem was the browser ScriptSafe extension which was turned on. Disabling it solved the issue



Answered By - feetnappy

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.