Skip to content

fix(landing-page): migrate CSP from unsafe-inline to nonce-based#715

Merged
JeremyDev87 merged 1 commit intomasterfrom
fix/csp-nonce-migration-703
Mar 20, 2026
Merged

fix(landing-page): migrate CSP from unsafe-inline to nonce-based#715
JeremyDev87 merged 1 commit intomasterfrom
fix/csp-nonce-migration-703

Conversation

@JeremyDev87
Copy link
Owner

Summary

  • Add config/csp.ts with buildCspHeader(nonce, env) function for dynamic CSP generation
  • Update middleware.ts to generate per-request cryptographic nonce via crypto.randomUUID()
  • Remove static CSP from next.config.ts — middleware now handles it dynamically with nonce
  • Add 14 CSP-related tests covering builder, middleware, and integration
  • Dev mode retains unsafe-eval + unsafe-inline for HMR compatibility

Test plan

  • 235 tests pass (39 test files)
  • lint, format, typecheck, coverage, circular checks all pass
  • Production build succeeds with PPR (Partial Prerender)
  • Nonce uniqueness verified per request
  • unsafe-inline removed from production script-src

Closes #703

- Add config/csp.ts with buildCspHeader(nonce, env) for CSP generation
- Update middleware.ts to generate per-request nonce via crypto.randomUUID()
- Remove static CSP from next.config.ts (middleware handles it dynamically)
- Add 14 CSP-related tests (builder + middleware + integration)

Closes #703
@vercel
Copy link

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codingbuddy-landing Ready Ready Preview, Comment Mar 19, 2026 8:25am

@JeremyDev87 JeremyDev87 self-assigned this Mar 20, 2026
@JeremyDev87 JeremyDev87 merged commit 3858ed0 into master Mar 20, 2026
25 checks passed
@JeremyDev87 JeremyDev87 deleted the fix/csp-nonce-migration-703 branch March 20, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(landing-page): migrate CSP from unsafe-inline to nonce-based

1 participant