内容安全策略指令:“script-src 'none' 违规错误
Content Security Policy directive: "script-src 'none' Violation Error
我刚刚安装了 MAMP 并在 htdocs 文件夹中创建了 2 个文件:
index.html
<!doctype html>
<html>
<body>Test Page</body>
<script src="script.js"></script>
</html>
script.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,但忘了重新打开。这很愚蠢,但我在这里回复,以便像我这样的人可以查看!
我刚刚安装了 MAMP 并在 htdocs 文件夹中创建了 2 个文件:
index.html
<!doctype html> <html> <body>Test Page</body> <script src="script.js"></script> </html>
script.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,但忘了重新打开。这很愚蠢,但我在这里回复,以便像我这样的人可以查看!