From a30da6de1c37d58a089120db8c556ab99ac3f0e3 Mon Sep 17 00:00:00 2001 From: harsh0641 Date: Thu, 19 Nov 2026 21:18:09 -0500 Subject: [PATCH 1/2] feat: enforce CSP --- web/next.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/next.config.ts b/web/next.config.ts index 433c34c..fcf3430 100644 --- a/web/next.config.ts +++ b/web/next.config.ts @@ -13,7 +13,7 @@ const securityHeaders = [ value: "max-age=63072000; includeSubDomains", }, { - key: "Content-Security-Policy-Report-Only", + key: "Content-Security-Policy", value: "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://lysis-3ocq.onrender.com https://*.supabase.co; frame-ancestors 'none'", }, From bb7be4feb4d2fc493790966548652c8482572855 Mon Sep 17 00:00:00 2001 From: harsh0641 Date: Thu, 19 Nov 2026 21:22:00 -0500 Subject: [PATCH 2/2] feat: enforce CSP --- web/next.config.ts | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/web/next.config.ts b/web/next.config.ts index fcf3430..58d5b65 100644 --- a/web/next.config.ts +++ b/web/next.config.ts @@ -1,5 +1,25 @@ import type { NextConfig } from "next"; +const apiOrigin = (() => { + try { + return new URL( + process.env.NEXT_PUBLIC_API_URL ?? "http://127.0.0.1:8000", + ).origin; + } catch { + return "http://127.0.0.1:8000"; + } +})(); + +const csp = [ + "default-src 'self'", + "script-src 'self' 'unsafe-inline'", + "style-src 'self' 'unsafe-inline'", + "img-src 'self' data: https:", + "font-src 'self' data:", + `connect-src 'self' ${apiOrigin} https://*.supabase.co`, + "frame-ancestors 'none'", +].join("; "); + const securityHeaders = [ { key: "X-Frame-Options", value: "DENY" }, { key: "X-Content-Type-Options", value: "nosniff" }, @@ -12,11 +32,7 @@ const securityHeaders = [ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains", }, - { - key: "Content-Security-Policy", - value: - "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://lysis-3ocq.onrender.com https://*.supabase.co; frame-ancestors 'none'", - }, + { key: "Content-Security-Policy", value: csp }, ]; const nextConfig: NextConfig = { @@ -35,4 +51,4 @@ const nextConfig: NextConfig = { }, }; -export default nextConfig; +export default nextConfig; \ No newline at end of file