3

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?

Gal Hadas
  • 31
  • 2

1 Answers1

1

Please make true like this in router module

RouterModule.forRoot(rootRouterConfig, { useHash: true})
barbsan
  • 3,418
  • 11
  • 21
  • 28
  • That's a perfect answer bro.. worked for me... !! Thanks. The error is clear though...!! How did you find it?? – Mr. Noddy Jan 30 '20 at 09:35