SPB Git
1.8 KB · 43 lines typescript
1import type { NextConfig } from "next";23const isProd = process.env.NODE_ENV === "production";4const csp = [5  "default-src 'self'",6  // Next.js needs inline bootstrap scripts; nonces are not used because pages are statically cached. No eval in production.7  isProd ? "script-src 'self' 'unsafe-inline'" : "script-src 'self' 'unsafe-inline' 'unsafe-eval'",8  "style-src 'self' 'unsafe-inline'",9  "img-src 'self' data: blob:",10  "font-src 'self' data:",11  "connect-src 'self'",12  "object-src 'none'",13  "base-uri 'self'",14  "form-action 'self'",15  "frame-ancestors 'none'",16  "upgrade-insecure-requests",17].join("; ");1819const securityHeaders = [20  { key: "X-Content-Type-Options", value: "nosniff" },21  { key: "X-Frame-Options", value: "DENY" },22  { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },23  { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), browsing-topics=()" },24  { key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains" },25  { key: "Cross-Origin-Opener-Policy", value: "same-origin" },26  { key: "Content-Security-Policy", value: csp },27];2829const nextConfig: NextConfig = {30  poweredByHeader: false,31  reactStrictMode: true,32  serverExternalPackages: ["postgres", "@node-rs/argon2"],33  async headers() {34    return [35      { source: "/(.*)", headers: securityHeaders },36      { source: "/admin/:path*", headers: [{ key: "X-Robots-Tag", value: "noindex, nofollow" }, { key: "Cache-Control", value: "no-store" }] },37      { source: "/login", headers: [{ key: "X-Robots-Tag", value: "noindex, nofollow" }, { key: "Cache-Control", value: "no-store" }] },38      { source: "/api/admin/:path*", headers: [{ key: "X-Robots-Tag", value: "noindex" }, { key: "Cache-Control", value: "no-store" }] },39    ];40  },41};42export default nextConfig;43
Files · 952c729898a51b6f66b840c63eac4034b9dc16f5
Menu

Theme