Repository Public
1import type { NextConfig } from "next";23// Static CSP: Next's inline bootstrap scripts need 'unsafe-inline' unless every page is rendered with a nonce.4// No third-party origin is allowed anywhere; no upgrade-insecure-requests (breaks WebKit on http://127.0.0.1 in tests).5const csp = [6 "default-src 'self'",7 // React's development build needs eval for its debugging features; production never gets it.8 `script-src 'self' 'unsafe-inline'${process.env.NODE_ENV === "production" ? "" : " 'unsafe-eval'"}`,9 "style-src 'self' 'unsafe-inline'",10 "img-src 'self' data: blob:",11 "media-src 'self' blob:",12 "manifest-src 'self'",13 "worker-src 'self'",14 "font-src 'self'",15 "connect-src 'self'",16 "frame-ancestors 'none'",17 "base-uri 'self'",18 "form-action 'self'",19 "object-src 'none'",20].join("; ");2122const config: NextConfig = {23 poweredByHeader: false,24 // The gateway (Caddy) compresses text; audio must keep its Content-Length and byte ranges untouched.25 compress: false,26 serverExternalPackages: ["postgres", "yauzl"],27 async headers() {28 return [29 {30 source: "/:path*",31 headers: [32 { key: "Content-Security-Policy", value: csp },33 { key: "X-Content-Type-Options", value: "nosniff" },34 { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },35 { key: "X-Frame-Options", value: "DENY" },36 { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), interest-cohort=()" },37 { key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },38 ],39 },40 ];41 },42};43export default config;44