I am facing an issue regarding the CSP (Content Security Policy) recently implemented in our project using Ngnix in angular 16. I have tried many solutions but still, the issue is not resolved. If anyone knows how to fix this issue let me know.
Some of the libraries are used in our project and they create some inline styles and elements automatically on the runtime browser
angular-split, angular-material
Console error:
Refused to apply inline style because it violates the following Content Security Policy directive: “style-src ‘self’ ‘nonce-8c65b1e1638652932ecdc7c995347a95′”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-biLFinpqYMtWHmXfkA1BPeCY0/fNt46SAZ+BBk5YUog=’), or a nonce (‘nonce-…’) is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes, and javascript: navigations unless the ‘unsafe-hashes’ keyword is present.
Below are the approaches that I have already tried.
https://content-security-policy.com/examples/allow-inline-st…
https://blog.stackademic.com/whats-a-nonce-7508458bded9
https://dev.to/ferdiesletering/how-to-implement-an-inline-st…
https://github.com/ferdiesletering/angular-csp-nonce
Ravi Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.