我刚刚安装了 MAMP 并在 htdocs 文件夹中创建了 2 个文件:
index.html
<!doctype html> <html> <body>Test Page</body> <script src="script.js"></script> </html>
脚本.js
console.log("works");
MAMP 配置到以下端口:
- Apache 端口:8888
- Nginx 端口:7888
- MySQL端口:8889
打开 localhost:8888
在控制台中出现以下错误:
Refused to load the script 'http://localhost:8888/script.js' because it violates the following Content Security Policy directive: "script-src 'none'".
我以前从未接触过 CSP,所以这让我感到困惑。是什么导致了这个问题?
最佳答案
原来这个问题的原因是浏览器ScriptSafe已打开的扩展程序。禁用它解决了问题
关于javascript - 内容安全策略指令 : "script-src ' none' Violation Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44439455/