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

查看:53
本文介绍了内容安全策略指令:“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...

我的应用链接是这里

手动导航到 my-pokedex 组件后我的应用程序的屏幕截图,存储在/mypokedex 路由中!(当我通过应用侧边栏导航到 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.这有点意思.这篇关于路由的 StackOverflow 帖子Angular-routing, direct URL navigation 可能有助于阐明到你所经历的.

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天全站免登陆