内容安全策略指令:" img-src数据:"错误

时间:2018-03-06 18:27:00

标签: angular angular5 content-security-policy

我在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 更改了它,将它放在我的assets文件夹中,并在index.html中设置它的相对路径(浏览器成功识别它!):

<link rel="icon" type="image/x-icon" href="/pokedex/assets/png/favicon.ico">

这个问题有解决办法吗?我以前从来没有过......

我的应用的链接是here

修改

手动导航到my-pokedex组件后,我的应用程序的屏幕截图,存储在/ mypokedex路由中! (当我通过app侧边栏导航到my-pokedex时,它没有任何问题!):

Screenshot

1 个答案:

答案 0 :(得分:0)

页面上的工作很好。我正在看演示,我没有看到图标有任何问题,我没有收到任何控制台错误消息。你还在看你的问题吗?如果是的话,错误消息的屏幕截图总是很​​好。

编辑1: 因此,您所获得的问题不一定是Content Security Policy指令,而是当您直接访问网址时获得404。这更有意义。这篇关于路由Angular-routing, direct URL navigation的StackOverflow帖子可能会帮助您了解您遇到的问题。