Content Security Policy blocks Angular Styles

Discussão em 'Angular' iniciado por superlazy, Outubro 23, 2024.

  1. superlazy

    superlazy Guest

    I want to publish a web application with a strict Content Security Policy. The last remaining issue is: style-src 'self';

    I get an error in the browser console saying that a resource was blocked from loading based on the style-src directive in the CSP. The error references code in the main..js file that is produced from ng build --prod.

    If I add 'unsafe-inline' to the style-src directive in the CSP, everything works fine, however, I do not want to do this.

    Is there anything I can do in my code or build option to make the web application work with the more restrictive CSP?

    I was using Angular 11 and just upgraded to 12 and have the same error.

    Thanks!

    Continue reading...

Compartilhe esta Página