Skip to content

Next.js 13: How to pass nonce as prop so that initial scripts receive it? #49648

Closed Locked Answered by leerob
tmb-github asked this question in Help
Discussion options

You must be logged in to vote

Hey folks, wanted to swing back here with an update. After digging through many different issues and discussions, I've made a new page in the documentation (PR) specifically for Content Security Policy and nonces. This docs page:

  • Explains how to generate a nonce with Middleware
  • Shows how to consume the nonce in a route with headers()
  • Shows a complete CSP without needing to use any unsafe
  • Shows how to ignore the nonce Middleware from running on prefetches / static assets

Further, we've patched some bugs and made improvements to nonce handling in Next.js that will be available in the latest canary version (for those of you time traveling from the future, upgrade to Next.js 13.5). We also …

Replies: 12 comments 25 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@vrajan1981
Comment options

@danieltott
Comment options

@sashimigud
Comment options

Comment options

You must be logged in to vote
12 replies
@danieltott
Comment options

@vrajan1981
Comment options

@danieltott
Comment options

@vrajan1981
Comment options

@karlhorky
Comment options

Comment options

You must be logged in to vote
7 replies
@karlhorky
Comment options

@danieltott
Comment options

@karlhorky
Comment options

@danieltott
Comment options

@karlhorky
Comment options

Comment options

You must be logged in to vote
3 replies
@danieltott
Comment options

@salazarm
Comment options

@danieltott
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by leerob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
Converted from issue

This discussion was converted from issue #42330 on May 11, 2023 09:08.