Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
Running nextjs development mode with CSP and "style-src" with nonce

I'm not able to get nextjs development mode running with "style-src" CSP active. Currently i have only 2 errors left, but these impact my development flow:

enter image description here

I think this 2 errors would be the styling for error display in development mode and the refresh spinner.

is there a way to fix this (adding nonce or something). I want to have the same CSP for development as for production to not produce CSP errors after build. (ie. using inline style somewhere). If i have to use "unsafe-inline" for development i will not be notified until changes are build and deployed.

Using __webpack_nonce__ also doesn't help.

Seams like the scripts try to inject a <script> element to the dom, but don't respect __webpack_nonce__. is there a way to force inject it to each element?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

With just the error messages to work with I assume that the code is either inserting a style tag or a style attribute. Attributes are not nonceable and also will not work with hashes in many (or all) browser implementations. If it is a style tag it is likely that the module setting it doesn't support nonces. Try inserting the hash provided in the error message. If there are variations to the style you may have add multiple hashes. If you need to keep adding hashes for a long time, the hash route is not for you. If these hashes aren't needed in production they still do no harm, except require a tiny bit of bandwidth.

If you need to resort to 'unsafe-inline' in general, this isn't very bad for style-src if you restrict other parts of your CSP, according to https://scotthelme.co.uk/can-you-get-pwned-with-css/.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!