简体   繁体   English

防止图像加载的内容安全策略

[英]Content Security Policy preventing images from loading

I have an express app which is loading some external assets, but they're getting blocked by CSP.我有一个正在加载一些外部资产的快速应用程序,但它们被 CSP 阻止。 I've never had this issue before, but this is the first time im using passport.js and helmet.js within an app so maybe this has something to do with their configuration?我以前从未遇到过这个问题,但这是我第一次在应用程序中使用passport.js 和helm.js 所以这可能与他们的配置有关吗?

Refused to load the image 'https://fake-url.com' because it violates the following Content Security Policy directive: "img-src 'self' data:".

I've tried adding a meta tag to allow images from external sources but this seems to have no effect.我尝试添加一个元标记以允许来自外部来源的图像,但这似乎没有效果。 Any help would be appreciated.任何帮助,将不胜感激。

You have你有

content="default-src 'none'

This prevents loading resources from any source.这可以防止从任何来源加载资源。 Remove it.去掉它。

Then change it to:然后将其更改为:

default-src 'self' fake-url.com';

More info bout the HTTP Content-Security-Policy response header below:有关以下 HTTP Content-Security-Policy响应标头的更多信息:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy

https://content-security-policy.com/ https://content-security-policy.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Content-Security-Policy 不会在 React 中从外部源加载图像 - Content-Security-Policy will not load images from external sources in React 由于 React 应用程序中的内容安全策略,图像未加载 - Image not loading due to content security policy in React app AWS中的内容安全策略 - Content Security Policy in AWS 如何使用React App无法正确加载与Content Security Policy相关的内容来解决Node.js问题 - how to correct issue with nodejs with react app not loading content properly related to Content Security Policy 如何从内容安全策略中删除不安全的内联和不安全的评估? - How to remove unsafe inline and unsafe eval from content security policy? Cordova-拒绝从设备连接到api(内容安全策略) - Cordova - Refused to connect to api from device (Content Security Policy) Content Security Policy nodejs program - Content Security Policy nodejs program 违反内容安全策略指令 - Violation of Content Security Policy directive 内容安全策略:页面的设置阻止自行加载资源(“ default-src”) - Content Security Policy: The page’s settings blocked the loading of a resource at self (“default-src”) 内容安全策略:页面设置阻止加载内联资源(“default-src”) - Content Security Policy: The page’s settings blocked the loading of a resource at inline (“default-src”)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM