Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Refused to load the script 'https://localhost:5000/_framework/123.js' because it violates the following Content Security Policy directive
I have set
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />

But it still doesn't work.

What I have tried:

<meta http-equiv="Content-Security-Policy" content="script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
Posted
Updated 27-Jan-21 21:29pm

Protocol is not matching(Your js URL & Host from Meta)
Try putting https://localhost instead of http://*

Check below page to learn about Content Security Policy & its syntax & samples
CSP Cheat Sheet[^]
 
Share this answer
 
`http://*` source covers `https://localhost:80` and `https://localhost:443` with standard ports only.
But you try to load script `https://localhost:5000/` with :5000 port number.

To fix the issue you have to add `https://localhost:5000` host-source to the script-src directive. Alternatively you can use syntax 'https://localhost:*' to allow any ports.

Note: `http://*` source covers both `http://*` and `https://*` because CSP3 browsers do upgrade insecure http: to a secure https:.
Therefore `http://site.com` allows both `http://site.com` and `https://site.com`.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900