Content-Security-Policy + Angular 8

Asked

Viewed 52 times

0

I am applying the following security policy in a project:

<meta http-equiv="Content-Security-Policy" content="script-src 'self'; style-src 'self'; img-src 'self';" />

On the console, I get the following errors:

Erros Console

I’ve tried to use:

npm build --prod npm run build --prod npm build --aot --prod

None of the other options worked. Has anyone gone through anything like this?

  • Have you tried ng build --prod?

1 answer

0

So Angular can apply dynamic styles to the elements in the keyword style-src you must complement with 'unsafe-inline'

<meta http-equiv="Content-Security-Policy" content="script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self';" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.