Skip to content
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

Docs: Incorrect headers() usage in the Content Security Policy example repository #77343

Open
diegocrivelaro opened this issue Mar 20, 2025 · 0 comments · May be fixed by #77352
Open

Docs: Incorrect headers() usage in the Content Security Policy example repository #77343

diegocrivelaro opened this issue Mar 20, 2025 · 0 comments · May be fixed by #77352

Comments

@diegocrivelaro
Copy link

What is the documentation issue?

Hello,

While following the "Content Security Policy" documentation, I cloned the linked example repository. However, when running yarn dev, I encountered an error due to the way headers() is called.

The current implementation in the example repository is:

const nonce = headers().get("x-nonce");  

However, this leads to an error because headers() is an async function. The correct approach should be:

const nonce = (await headers()).get("x-nonce");  

It would be great to have it updated to avoid confusion for other developers.

Image

Is there any context that might help us understand?

The issue is specifically in the file: next.js/examples/with-strict-csp/app/page.js

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/building-your-application/configuring/content-security-policy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant