Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content-Security-Policy: Refused to execute inline script on lite server

I am following angular's best practice in order to make PWA. After making production build (ng built --prod --aot). I am also running from dist on localhost: npm run dev ("dev": "lite-server"). When the browser load I get an error in the console:

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-EzX1NiGgmo59Hi8wZ/thoAxnVbkTfzIAgnVddwzUO3Y='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

I tried to add to index.html: <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-eval' 'unsafe-inline';">

What am I doing wrong?

like image 285
Gal Hadas Avatar asked Jul 13 '26 01:07

Gal Hadas


1 Answers

Please make true like this in router module

RouterModule.forRoot(rootRouterConfig, { useHash: true})
like image 61
Guguloth Suresh Avatar answered Jul 15 '26 17:07

Guguloth Suresh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!