Middleware added Nonce attributes missing from TypeScript production builds #66871
Labels
bug
Issue was opened via the bug report template.
Documentation
Related to Next.js' official documentation.
Middleware
Related to Next.js Middleware
TypeScript
Related to types with Next.js.
Link to the code that reproduces this issue
https://github.com/andymagill/csp-middleware-nextjs-bug/tree/main
To Reproduce
yarn create next-app --example reproduction-template reproduction-app
yarn install
thenyarn run build
thenyarn run start
Current vs. Expected behavior
Current behavior: nonce attributes are missing from bundles
Expected behavior: nonce attributes are present on bundles
Provide environment information
Which area(s) are affected? (Select all that apply)
Documentation, Middleware, TypeScript
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
This behavior appears to be specific to production builds of next.js typescript middleware. Running
yarn run dev
in the example repo works fine and correctly adds the nonce. The "with-strict-csp" example with the middleware.JS (not ts) also correctly adds the nonce on production builds.Currently, I see no way to add nonces to Next.JS TypeScript projects using the documented methods.
The text was updated successfully, but these errors were encountered: