From 272f70da5219915484ce9f8111f7b4af885c177b Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Wed, 8 Jul 2026 20:07:29 +0800 Subject: [PATCH 1/3] security(csp): migrate script-src from 'unsafe-inline' to per-request nonce Production `script-src` is now `'self' 'nonce-' 'strict-dynamic'` with no `'unsafe-inline'`. The nonce is generated per request in the Next 16 proxy (`src/proxy.ts`), threaded into SSR via the `x-nonce` and CSP request headers so Next stamps its own bootstrap/bundle/flight scripts automatically, and applied explicitly to the one hand-authored inline script (the theme-flash guard in `src/app/layout.tsx`). Reading the nonce opts the app into dynamic rendering, which is inherent to per-request nonces. CSP now lives in the proxy (a nonce can't be a build-time constant); all other CSP directives and every other security header are unchanged and still emitted statically from `next.config.ts` via `buildSecurityHeaders` (CSP removed from that set so there is exactly one CSP header per response). Development keeps the pre-migration `'self' 'unsafe-inline' 'unsafe-eval'` with no `'strict-dynamic'`: the Turbopack dev server injects non-nonced HMR and route-chunk `