fix(csp): allow inline scripts so Next.js client forms hydrate
script-src was 'self' with no 'unsafe-inline' and no nonce, so the browser blocked Next.js App Router's inline hydration scripts (RSC flight data + bootstrap). React never hydrated, so every client form's handler never attached and the browser fell back to a native GET submit — login dumped email/password into the URL and did nothing, and the registration/reset forms were equally dead. Add 'unsafe-inline' to script-src; per-request nonces via middleware remain the upgrade path. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
e6baaddca6
commit
3316365b73
1 file changed
+8
-4
+8
-4
@@ -10,12 +10,16 @@ const nextConfig: NextConfig = {
|
|||||||
headers: [
|
headers: [
|
||||||
{
|
{
|
||||||
key: "Content-Security-Policy",
|
key: "Content-Security-Policy",
|
||||||
// ponytail: restrictive CSP — 'unsafe-inline' for styles only
|
// ponytail: Next.js App Router injects inline scripts (RSC flight
|
||||||
// because Next.js injects inline styles. No unsafe-inline for
|
// data + bootstrap) to hydrate client components. Without
|
||||||
// scripts. Upgrade path: nonces once Next supports them per-route.
|
// 'unsafe-inline' or a nonce in script-src the browser blocks them,
|
||||||
|
// hydration never runs, and every client form (login, registration,
|
||||||
|
// reset) falls back to a native GET submit. 'unsafe-inline' for
|
||||||
|
// scripts is the pragmatic fix; upgrade path is per-request nonces
|
||||||
|
// via middleware (Next attaches the nonce to its inline scripts).
|
||||||
value: [
|
value: [
|
||||||
"default-src 'self'",
|
"default-src 'self'",
|
||||||
"script-src 'self'",
|
"script-src 'self' 'unsafe-inline'",
|
||||||
"style-src 'self' 'unsafe-inline'",
|
"style-src 'self' 'unsafe-inline'",
|
||||||
"img-src 'self' data:",
|
"img-src 'self' data:",
|
||||||
"font-src 'self'",
|
"font-src 'self'",
|
||||||
|
|||||||
Reference in new issue
Block a user