简体   繁体   English

无法在重新加载页面上获取 /login Angular 8 - 拒绝加载图像“/favicon.ico”,因为它违反了以下内容安全策略

[英]Cannot GET /login on reload pages Angular 8 - Refused to load the image '/favicon.ico' because it violates the following Content Security Policy

Getting this error Cannot GET login/ on the page body.出现此错误无法在页面正文上获取登录名/。 How to fix this error in latest angular 8 app.如何在最新的 angular 8 应用程序中修复此错误。 I have tried all the solutions from the forums but no luck.我已经尝试了论坛中的所有解决方案,但没有运气。 Any suggestions would be greatly appreciated.任何建议将不胜感激。

Please note no compilation errors in ng serve, ng biuld --prod .请注意ng serve, ng biuld --prod中没有编译错误。 Below is the chrome console error.下面是 chrome 控制台错误。 This error occurs only on the server url not in localhost.此错误仅发生在服务器 url 上,不在 localhost 中。

Refused to load the image 'serverUrL/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'".拒绝加载图像“serverUrL/favicon.ico”,因为它违反了以下内容安全策略指令:“default-src 'none'”。 Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.请注意,'img-src' 没有显式设置,因此 'default-src' 用作后备。

Try this..尝试这个..

Method 1方法一

  • Clean cache (npm cache clean --force)清理缓存(npm cache clean --force)
  • Delete node_modules folder (rm -rf node_modules)删除 node_modules 文件夹(rm -rf node_modules)
  • Delete package-lock.json file (rm -f package-lock.json)删除 package-lock.json 文件(rm -f package-lock.json)
  • Do fresh install (npm install)进行全新安装(npm install)

Method 2方法二

  • Update nodejs更新nodejs

Method 3方法三

Update the following code within head section of index.html更新 index.html 的 head 部分中的以下代码

<meta http-equiv="Content-Security-Policy" content="default-src 'self'
https://yourdomain.com;">

Content-Security-Policy (CSP)内容安全策略 (CSP)

CSP Directive: default-src CSP 指令:default-src

CSP value: 'self' (Restrict source to same origin) CSP 值:'self'(将源限制为同源)

References参考

More at Github Angular repo更多在 Github Angular 回购

About Content Security Policy 关于内容安全政策

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 拒绝加载图像,因为它违反了以下内容安全策略指令(图标) - Refused to load the image because it violates the following Content Security Policy directive (favicon) Angular 8 拒绝加载加载图像,因为它违反了以下内容安全策略指令 - Angular 8 refused to load load the image because it violates the following Content Security Policy directive 拒绝加载图像,因为它违反了以下内容安全策略指令:“default-src 'none'”。 角度 8 - Refused to load the image because it violates the following Content Security Policy directive: "default-src 'none'". Angular 8 Angular + bootstrap throws error 拒绝加载图像,因为它违反了以下内容安全策略指令:“default-src 'none'” - Angular + bootstrap throws error Refused to load the image because it violates the following Content Security Policy directive: “default-src 'none'” 角路由“拒绝加载字体”,因为它违反了以下内容安全策略” - Angular routing 'Refused to load the font '…' because it violates the following Content Security Policy' 错误号 angular:“拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script-src 'self'” - Error no angular: "Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'" 连接被拒绝:localhost:4200 favicon.ico 502 in angular 7 - Connection refused: localhost:4200 favicon.ico 502 in angular 7 如何更改 Angular 中的 favicon.ico 路径? - How to change favicon.ico path in Angular? 无法在生产中加载图像,违反内容安全策略指令:“img-src 'self' data - Cannot load images on production, violates Content Security Policy directive: "img-src 'self' data 内容安全策略指令:拒绝加载字体 - Content Security Policy directive: Refused to load the font
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM