// BACKLOG P0-13 (SEC-06): the app previously shipped no security headers of // its own -- HSTS existed only as a platform default injected by Vercel, so // it would have silently disappeared on cutover to Coolify/Traefik (see // docs/architecture/ARCHITECTURE.md §5/§8). These are set here, at the // framework level, so they travel with the app regardless of host. // // CSP is same-origin-only (`'self'`) plus the minimum carve-outs this app // actually needs today: // - `'unsafe-inline'` on script-src/style-src: Next.js's App Router injects // small inline hydration/RSC payload scripts and Tailwind can emit // inline style attributes; this repo doesn't yet wire a per-request // nonce through middleware+layout (a real follow-up -- see BACKLOG -- // but out of scope for this pass, which fixes "zero headers", not "zero // inline script tolerance"). // - `form-action` allows Stripe's hosted Checkout domains: the payment // flow (app/api/payments/[order_id]/deposit) does a full top-level // redirect to a Stripe-hosted page, never an embedded iframe/script // (grep-verified: no @stripe/stripe-js dependency, no client-side // Stripe.js load anywhere in app/). // No other third-party origins are contacted from the browser (no // analytics, no next/font/google, no embedded widgets -- grep-verified). const securityHeaders = [ { key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" }, { key: "X-Frame-Options", value: "DENY" }, { key: "X-Content-Type-Options", value: "nosniff" }, { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" }, { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), interest-cohort=()" }, { key: "Content-Security-Policy", value: [ "default-src 'self'", "script-src 'self' 'unsafe-inline'", "style-src 'self' 'unsafe-inline'", "img-src 'self' data: blob:", "font-src 'self' data:", "connect-src 'self'", "form-action 'self' https://checkout.stripe.com https://api.stripe.com", "frame-ancestors 'none'", "base-uri 'self'", "object-src 'none'", ].join("; "), }, ] /** @type {import('next').NextConfig} */ const nextConfig = { typescript: { ignoreBuildErrors: true, }, images: { unoptimized: true, }, async headers() { return [ { source: "/(.*)", headers: securityHeaders, }, ] }, } export default nextConfig