import type { NextConfig } from "next"; const isProd = process.env.NODE_ENV === "production"; /** * Content-Security-Policy. Inline styles are required by Tailwind's runtime-free * output only for a few third-party components (Radix measures via style attrs), * and Next.js injects inline scripts for hydration; nonces are not used because the * app is fully static-shell + client-fetch and `next start` runs behind ngrok. */ const csp = [ "default-src 'self'", "base-uri 'self'", "frame-ancestors 'none'", "form-action 'self'", "object-src 'none'", "img-src 'self' data: blob: https:", "font-src 'self' data:", "style-src 'self' 'unsafe-inline'", isProd ? "script-src 'self' 'unsafe-inline'" : "script-src 'self' 'unsafe-inline' 'unsafe-eval'", "connect-src 'self'", "worker-src 'self' blob:", "upgrade-insecure-requests", ].join("; "); const nextConfig: NextConfig = { reactStrictMode: true, poweredByHeader: false, agentRules: false, serverExternalPackages: ["pg", "argon2", "resend", "@anthropic-ai/sdk", "openai", "@google/genai", "shiki"], experimental: { serverActions: { bodySizeLimit: "2mb" }, }, async headers() { return [ { source: "/(.*)", headers: [ { 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=(), payment=()" }, { key: "Content-Security-Policy", value: csp }, ...(isProd ? [{ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" }] : []), ], }, ]; }, }; export default nextConfig;