【发布时间】:2018-02-14 12:53:25
【问题描述】:
我对内容安全策略有疑问。每当我尝试将 JavaScript 包含到我的项目中时,都会收到内容安全策略错误。
<!DOCTYPE html>
<html>
<head>
<title>Symfony</title>
<script src="{{ asset('myscript.js') }}"></script>
</head>
<body>
// ...
</body>
</html>
我做错了什么?
我已经尝试过:
- .htaccess:
Header set Content-Security-Policy "script-src 'self';" - html:
<meta http-equiv="Content-Security-Policy" content="script-src 'self'"> - https://ikvasnica.com/blog/how-to-protect-php-application-from-xss-attacks-csp-3-nonce/
【问题讨论】:
-
你使用哪个版本的 symfony?您可以复制/粘贴您的配置吗?您的资产网址是否在 https 下?文档 (symfony.com/blog/…)
-
我使用的是 Symfony 3.4 版本,所有 url 都在 http 下。配置与安装后相同。
标签: javascript php symfony content-security-policy easyadmin