-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Including hash values in directive breaks development #71
Comments
style-src
breaks development styles
you can resolve this, by adding arbitrary custom hashes with next-safe-middleware/apps/e2e/pages/_document.tsx Lines 39 to 50 in c407570
The concrete case why I added this was for dealing things like I didn't expect your case in the Edit: What I wrote above is wrong. You have to add the respective inline styles from your document as string to the array, they will be hashed then. |
For our application we have a few HTML documents which are provided by an external API, which we then inject into a shadow dom to render to the user in a modal.
Because these documents contain some inline style blocks (primarily for formatting when the user downloads them directly from our API as a PDF) we're required to provide these to the CSP as hashes.
In development, where
isDev
is set to true, this ultimately breaks all styles as theunsafe-inline
value gets overridden by the hashes being present in the style directive.Not sure of what the best fix for this would be, if there is one. As a workaround we've wrapped the hashes with a conditional to only spread them into the style directive if the environment isn't
development
, but this isn't ideal as it creates a difference between the CSP applied in dev vs. production.Not sure if this is something that can be handled more correctly/elegantly in the library itself based on
isDev
, but I guess it too risks having unexpected side effects where manually provided hashes are required in the development environment.The text was updated successfully, but these errors were encountered: