我在 HTTPS 上有一个网站,我正在使用相对链接链接到图像。我正在使用 rails helper 生成链接
<%= image_tag url_for(screenshot.attachment) %>
这会产生一个图像标签,如
<img src="/rails/blobs/myimage.jpg"/>
尽管该站点使用 HTTPS 并且我使用的是相对路径,但我收到以下 CSP 错误
Refused to load the image 'http://example.com/rails/blobs/myimage.jpg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22screenshot.jpg%22%3B+filename%2A%3DUTF-8%27%27screenshot.jpg'
because it violates the following Content Security Policy directive: "img-src 'self' https: data:".
我不明白为什么它试图从 HTTP 加载图像。
从你的 nginx 配置必须做 https 转发。然后这个问题会得到照顾。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句