内容安全政策指令:"img-src数据:"错误 [英] Content Security Policy directive: "img-src data:" error

查看:654
本文介绍了内容安全政策指令:"img-src数据:"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在github页面上测试Angular 5应用程序,每当我重新加载除index.html以外的页面时,都会出现此错误:

I'm testing my Angular 5 app on github pages, and whenever I reload a page other than index.html, I get this error:

Refused to load the image 'https://sebamed.github.io/favicon.ico' because it violates the following Content Security Policy directive: "img-src data:".

此外,当我尝试访问"404"错误页面时,也会收到相同的消息.

Also, when I try to access the '404' error page, I get the same message.

现在,我对此尝试了几种解决方案,但是似乎都没有一项工作.我什至将此添加到我的index.html:

Now, I tried several solutions on this, but none of them seems to do a job. I even added this to my index.html:

<meta http-equiv="Content-Security-Policy" content="img-src * 'self' data: https:">

但什么也没发生.

我已经使用自己的默认语言更改了Angular 5 favicon.ico ,将其放在我的资产文件夹中,并在index.html中为其设置了相对路径(浏览器已成功识别它!):

I have changed the default Angular 5 favicon.ico with my own, put it inside my assets folder, and set a relative path for it in index.html (browser recognizes it successfully!):

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

这个问题有解决方案吗?我从来没有过...

Is there any solution for this problem? I've never had it before...

我的应用程序的链接是此处

Link of my app is here

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

Screenshot of my app after manually navigating to my-pokedex component, stored in /mypokedex route! (when I navigate to my-pokedex via app sidebar, it works with no issues!):

截图

推荐答案

页面上的好工作.我在看演示,没有看到图标有任何问题,也没有收到任何控制台错误消息.您还在看问题吗?如果是这样,则错误消息的屏幕快照总是很好的.

Good job on the page. I was looking at the demo, and I'm not seeing anything wrong with the icons and I'm not getting any console error messages. Are you still seeing your issue? If you are, a screenshot of the error message is always good.

修改1: 因此,您遇到的问题不一定是Content Security Policy指令,而是直接进入URL时会得到404.这更有意义.关于路由 Angular路由,直接URL导航的这篇StackOverflow帖子可能有助于阐明到您正在经历的事情.

Edit 1: So the issue you're getting isn't necessarily the Content Security Policy directive, but that you're getting a 404 when you're going to a URL directly. That makes a bit more sense. This StackOverflow post about routing Angular-routing, direct URL navigation might help shed some light as to what you're experiencing.

这篇关于内容安全政策指令:"img-src数据:"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆