[Feature] Provide a way to be able to specify a nonce for styles used by next-dev-overlay #83440
lucasbasquerotto
started this conversation in
Ideas
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Be able to use a strict style CSP in development mode (
style-src
with anonce
instead ofunsafe-inline
).Non-Goals
No response
Background
I was able to use CSP with
nonce
in production, but on development almost everything is fine, except NextJS styles that are used for some development stuff, that stays at the bottom left of the page, showing errors, if uses turbopack, etc., and, unless I defineunsafe-inline
forstyle-src
in dev mode, this part is rendered incorrectly, and the console shows lots of style errors due to CSP.Keeping
unsafe-inline
in dev mode may make some styles that should havenonce
not show errors in this mode, instead, I could end up detecting them only in a production environment, which would be undesirable.You can see that the official example of CSP by NextJS show just a gray rectangle at the top left part of the page instead of the stylized button at the bottom left, and give
style-src
errors:To simulate the error:
Proposal
Either make
next-dev-overlay
retrieve the value of the headerx-nonce
as thenonce
value for the styles that are included in dev mode bynext-dev-overlay
(this would be the best approach), or make a way to specify a staticnonce
(in dev mode, a staticnonce
is fine, as there should be no security implication in dev mode regarding CSP, and removingunsafe-inline
would already help a lot in detecting issues in styles not usingnonce
, instead of detecting them only in a production environment).Beta Was this translation helpful? Give feedback.
All reactions