[英]Cannot load images on production, violates Content Security Policy directive: "img-src 'self' data
[英]Content Security Policy directive: "img-src data:" error
我正在 github 页面上测试我的 Angular 5 应用程序,每当我重新加载 index.html 以外的页面时,我都会收到此错误:
Refused to load the image 'https://sebamed.github.io/favicon.ico' because it violates the following Content Security Policy directive: "img-src data:".
此外,当我尝试访问“404”错误页面时,我会收到相同的消息。
现在,我对此尝试了几种解决方案,但似乎都没有奏效。 我什至将它添加到我的 index.html 中:
<meta http-equiv="Content-Security-Policy" content="img-src * 'self' data: https:">
但什么也没发生。
我已经用我自己的更改了默认的 Angular 5 favicon.ico ,将它放在我的资产文件夹中,并在 index.html 中为其设置了相对路径(浏览器成功识别它!):
<link rel="icon" type="image/x-icon" href="/pokedex/assets/png/favicon.ico">
这个问题有什么解决办法吗? 我以前从来没有过...
我的应用程序链接在这里
编辑:
手动导航到 my-pokedex 组件后我的应用程序的屏幕截图,存储在 /mypokedex 路由中! (当我通过应用侧边栏导航到 my-pokedex 时,它可以正常工作!):
在页面上做得很好。 我正在查看演示,我没有看到图标有任何问题,也没有收到任何控制台错误消息。 你还在看你的问题吗? 如果你是,错误消息的屏幕截图总是好的。
编辑 1:因此,您遇到的问题不一定是Content Security Policy
指令,而是当您直接访问 URL 时会收到 404。 这更有意义。 这篇关于路由Angular 路由、直接 URL 导航的StackOverflow 帖子可能有助于了解您所遇到的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.