SPB Git

Repository Public

next.config.ts 1.8 KB 44 lines typescript

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 compresses responses.25  compress: false,26  serverExternalPackages: ["postgres", "playwright-core", "@anthropic-ai/sdk"],27  async headers() {28    const common = [29      { key: "X-Content-Type-Options", value: "nosniff" },30      { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },31      { key: "X-Frame-Options", value: "DENY" },32      { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },33      { key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },34    ];35    return [36      // Stored files (uploads, exports) are answered by their own route with a stricter, sandboxed policy:37      // they are excluded here so that the site policy does not replace it.38      { source: "/((?!media/|api/admin/assets/|render/[^/]+/asset/).*)", headers: [{ key: "Content-Security-Policy", value: csp }, ...common] },39      { source: "/(media|api/admin/assets|render)/:path*", headers: common },40    ];41  },42};43export default config;44
Files main
Menu

Theme