简体   繁体   中英

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. 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 . Below is the chrome console error. This error occurs only on the server url not in localhost.

Refused to load the image 'serverUrL/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

Try this..

Method 1

  • Clean cache (npm cache clean --force)
  • Delete node_modules folder (rm -rf node_modules)
  • Delete package-lock.json file (rm -f package-lock.json)
  • Do fresh install (npm install)

Method 2

  • Update nodejs

Method 3

Update the following code within head section of index.html

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

Content-Security-Policy (CSP)

CSP Directive: default-src

CSP value: 'self' (Restrict source to same origin)

References

More at Github Angular repo

About Content Security Policy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM