我正面临着一个奇怪的错误,我无法弄清楚。当试图将一个小型项目部署到AWS Elastic Beanstalk实例时,我遇到了一些CSP错误。它似乎在抱怨执行内联脚本,尽管我的项目不包含JavaScript,除了一个小的Node.js后端来处理一些路由。我得到的错误是这样的:AWS内容安全策略
Refused to execute inline script because it violates the following
Content Security Policy directive: "script-src
https://d2aafqm3hbgbf6.cloudfront.net
https://d2q66yyjeovezo.cloudfront.net
https://d1idiovbex4hy4.cloudfront.net
https://d3e2aud6m9sl41.cloudfront.net https://phd.aws.amazon.com
https://resources.console.aws.amazon.com https://signin.aws.amazon.com
*.signin.aws.amazon.com https://d36cz9buwru1tt.cloudfront.net
https://media.amazonwebservices.com 'self'". Either the 'unsafe-inline'
keyword, a hash ('sha256-
WkLxG82JrIV0IxhYdEMt3pgYi6ZRYB9ZAj35iFKh8N8='), or a nonce
('nonce-...') is required to enable inline execution.
我试图CSP头添加到我的两个Node.js的后端和HTML文件它所服务的所有请求。
app.use(function(req, res, next){
res.header("Content-Security-Policy", "default-src * 'unsafe-inline'
'unsafe-eval' data: blob:;");
next();
})
Meta标记:
<meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval' data: blob:;">
有人可以请帮我找出我要去的地方错了吗?
谢谢