-
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
No script is having nonce generated #74
Comments
Thanks @nibtime for all the hard work on this module. I finally had some time to get back to this whole topic for a bit but I am observing a similar behavior. No nonce is applied on the scripts either and I get reporting errors all over the place. Is this to be expected on the next 12.2.X? Adding the |
Been digging around the repo and have noticed this in the
|
Ahh, I did wonder if it was because I was running in development mode. Should have looked through the git repo a little more. Thank you for your help with this. I removed this package and wrote a middleware myself that deals with CSP but I may replace it with this package again as its a lot cleaner. In my opinion, I do believe that its wrong to only apply the nonces in production mode. It is often the case, especially with strict CSP, that you want/need to test it on development. Perhaps a boolean argument could be added to the middleware package instead, rather than checking for NODE_ENV? |
Yeah, I eventually stumbled upon it and it worked! That being said, I think it's helpful to have it in dev although I am sure @nibtime has some thoughts on this as well. This problem is not easy to solve as a whole, especially given how much Next.js has been changing recently (see #60). I think we'll take inspiration from this module and from As for CSP, I think we'll have to compromise for a start but would be nice to have a solution without middleware as well since the API is changing a lot. NODE_ENV="production" is true if you build your app locally and then start the server on that, granted, not as nice to debug but still a good way to get it to run locally 👍 |
We're having the same problem with not being able to test nonce's in pre-Prod enviroments. @nibtime - I understand a boolean to turn off noncing could create problems if it was set wrong on Prod. To keep the strict approach but support nonce testing, would you consider booleans for common down-level env's? Like:
|
TLDR
No nonces or hashes are being provided.
Problem
I have requirements for very strict-csp, so without nonces, the web-application can not be loaded. I have followed the documentation + the e2e pages and am unable to get further than the CSP directives being loaded. I am receiving no hashes or nonces. I have tried using both gsspWithNonce & gsspWithNonceAppliedToCsp. Unfortunately the nonce prop provided is always an empty string. I am also unable to get any scripts, links or styles within the provided head tag to become CSP compliant. (Well, I am CSP compliant, just nothing loads if not in report-mode!)
This is what my chunks look like in the inspector.
And this is the e2e examples chunks, notice the nonce tag on every script and link.
I am wondering if I am doing something seriously wrong when using this package. I have noticed a lot of changes in the changelog. For instance nonces are no longer auto-injected due to changes in next.js 12.2.X?
I have created a skeleton project with the package installed and a similar setup to the real codebase I am working on. It uses pnpm and has a patch for Next.js 12.2.5 to remove eval-source-map from the webpack config.
https://github.com/VayneValerius/next-safe-middleware-test
Info
_document.tsx
middleware.ts
index.tsx
The text was updated successfully, but these errors were encountered: