![](/img/trans.png)
[英]Cannot load images on production, violates Content Security Policy directive: "img-src 'self' data
[英]Refused to load the image '<URL>' because it violates the following Content Security Policy directive: "img-src 'self' data:"
在我將我的網站上傳到 herokuy 后,圖像無法正常工作,這給了我這個錯誤
拒絕加載圖像'',因為它違反了以下內容安全策略指令:“img-src 'self' data:”。
我嘗試過類似的東西
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; font-src data:" />
但它也不起作用
這將禁用contentSecurityPolicy
中間件,但保留 rest:
app.use(
helmet({
contentSecurityPolicy: false,
})
);
app.use(helmet({ crossOriginEmbedderPolicy: false, originAgentCluster: true }));
app.use(
helmet.contentSecurityPolicy({
useDefaults: true,
directives: {
"img-src": ["'self'", "https: data: blob:"],
},
})
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.