From 19ee02ac6c743e4cc87e22c39547c15de6408be5 Mon Sep 17 00:00:00 2001 From: Nico Date: Sun, 15 Feb 2026 01:08:07 -0800 Subject: [PATCH] fix web csp for next runtime hydration --- apps/web/next.config.mjs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs index 1008e22..eec9c14 100644 --- a/apps/web/next.config.mjs +++ b/apps/web/next.config.mjs @@ -1,9 +1,22 @@ +const isDev = process.env.NODE_ENV !== "production"; + +const csp = [ + "default-src 'self'", + "img-src 'self' data: blob:", + "style-src 'self' 'unsafe-inline'", + `script-src 'self' 'unsafe-inline'${isDev ? " 'unsafe-eval'" : ""}`, + `connect-src 'self'${isDev ? " ws: wss:" : ""}`, + "frame-ancestors 'none'", + "base-uri 'self'", + "form-action 'self'" +].join("; "); + const securityHeaders = [ { key: "X-Content-Type-Options", value: "nosniff" }, { key: "X-Frame-Options", value: "DENY" }, { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" }, { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" }, - { key: "Content-Security-Policy", value: "default-src 'self'; img-src 'self' data: blob:; style-src 'self' 'unsafe-inline'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" } + { key: "Content-Security-Policy", value: csp } ]; /** @type {import('next').NextConfig} */