How to use Csp Policy without sri enabled in SSR mode #156
Unanswered
discoverlance-com
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using the node adapter to output server mode in my astro application.
I have setup the following shield content:
When I enable (uncomment) the sri part of my shield config, I get csp errors (Refused to apply inline style because it violates the following Content Security Policy directive: ...). The error is coming from a react component with a
client:loadclient component directive.I added 'unsafe-inline' to my 'style-src' directive in my csp policy but that does not solve the issue because sri basically generates hashes and CSP ignores 'unsafe-inline' if there's a hash or nonce in the policy.
But I realised that when I remove the sri (as seen in the code commented above), the csp policy header is not added at all for my pages. I built my app after removing the sri directive and there's no CSP header on my page after checking my network tab. I think it might partly be due to the fact that the csp is added to the middleware from the sri options so without it, it does not work for server pages.
Is there any way around this? Am I perhaps not on the right track in trying to find a solution to this?
Beta Was this translation helpful? Give feedback.
All reactions