Skip to content

[docs] Always include unsafe-eval in dev Content-Security-Policy#89163

Merged
eps1lon merged 3 commits intocanaryfrom
cursor/docs-csp-unsafe-eval-development-e658
Jan 28, 2026
Merged

[docs] Always include unsafe-eval in dev Content-Security-Policy#89163
eps1lon merged 3 commits intocanaryfrom
cursor/docs-csp-unsafe-eval-development-e658

Conversation

@eps1lon
Copy link
Member

@eps1lon eps1lon commented Jan 28, 2026

eval is critical for React's Server error/console replaying to work.
We included unsafe-eval in the CSP in some examples but not all. Now we include unsafe-eval everywhere.

Part of https://linear.app/vercel/issue/NAR-754/


Slack Thread

Open in Cursor Open in Web

Update CSP documentation examples to check for development mode
before adding 'unsafe-eval' to script-src directive:

- Proxy examples with nonces now include isDev check
- SRI configuration example now includes isDev check
- Prevents unsafe-eval from being shipped to production

This aligns all examples with the existing 'Without Nonces' and
'Development Environment' sections that already had proper checks.

Co-authored-by: sebastian.silbermann <sebastian.silbermann@vercel.com>
@cursor
Copy link
Contributor

cursor bot commented Jan 28, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@nextjs-bot nextjs-bot added created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. labels Jan 28, 2026
@eps1lon eps1lon changed the title Docs CSP unsafe-eval development [docs] Always include unsafe-eval in dev Content-Security-Policy Jan 28, 2026
Add explanation that React uses eval to provide enhanced debugging
information, such as reconstructing server-side error stacks in the
browser to show where errors originated on the server.

Co-authored-by: sebastian.silbermann <sebastian.silbermann@vercel.com>
@nextjs-bot
Copy link
Collaborator

Allow CI Workflow Run

  • approve CI run for commit: 95c9263

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@eps1lon eps1lon added the CI approved Approve running CI for fork label Jan 28, 2026
@eps1lon eps1lon requested a review from icyJoseph January 28, 2026 13:11
@eps1lon eps1lon marked this pull request as ready for review January 28, 2026 13:11
@icyJoseph
Copy link
Member

icyJoseph commented Jan 28, 2026

Approving but I wonder if the Third-party scripts section should also have the isDev check? @cursor

@eps1lon
Copy link
Member Author

eps1lon commented Jan 28, 2026

Why should this section not have unsafe-eval? Unless we specifically talk about 3rd party scripts requiring eval but this feels out-of-scope for framework docs.

@icyJoseph
Copy link
Member

Mmm maybe I am misreading something here, but we have https://nextjs.org/docs/app/guides/content-security-policy#third-party-scripts with:

const cspHeader = `
  default-src 'self';
  script-src 'self' 'nonce-${nonce}' 'strict-dynamic' https://www.googletagmanager.com;
  connect-src 'self' https://www.google-analytics.com;
  img-src 'self' data: https://www.google-analytics.com;
`

This should also have the unsafe-eval for dev right?

@eps1lon
Copy link
Member Author

eps1lon commented Jan 28, 2026

yes. @cursor please add a dev-only unsafe-eval to every potential CSP header on this page

@eps1lon eps1lon merged commit 7a44309 into canary Jan 28, 2026
70 of 72 checks passed
@eps1lon eps1lon deleted the cursor/docs-csp-unsafe-eval-development-e658 branch January 28, 2026 21:26
icyJoseph pushed a commit that referenced this pull request Feb 9, 2026
…89163)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CI approved Approve running CI for fork created-by: Next.js team PRs by the Next.js team. Documentation Related to Next.js' official documentation. locked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants