我正面臨着一個奇怪的錯誤,我無法弄清楚。當試圖將一個小型項目部署到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:;">
有人可以請幫我找出我要去的地方錯了嗎?
謝謝