Repository Public
1import type { NextConfig } from "next";23const preview = process.env.ATLAS_PREVIEW === "1";45// Static CSP: Next's inline bootstrap scripts need 'unsafe-inline' unless every page is rendered with a6// nonce (which would forbid static generation). No third-party origin is allowed anywhere: no analytics,7// no remote fonts, no CDN. blob: is needed by hls.js (MediaSource object URLs and its transmuxing worker).8const csp = [9 "default-src 'self'",10 `script-src 'self' 'unsafe-inline'${process.env.NODE_ENV === "production" ? "" : " 'unsafe-eval'"}`,11 "style-src 'self' 'unsafe-inline'",12 "img-src 'self' data: blob:",13 "media-src 'self' blob:",14 "worker-src 'self' blob:",15 "font-src 'self'",16 "connect-src 'self'",17 "manifest-src 'self'",18 "frame-ancestors 'none'",19 "base-uri 'self'",20 "form-action 'self'",21 "object-src 'none'",22].join("; ");2324const common = [25 { key: "X-Content-Type-Options", value: "nosniff" },26 { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },27 { key: "X-Frame-Options", value: "DENY" },28 { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), browsing-topics=(), interest-cohort=()" },29 { key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },30 { key: "Cross-Origin-Opener-Policy", value: "same-origin" },31 // A preview build must never be indexed, whatever robots.txt says.32 ...(preview ? [{ key: "X-Robots-Tag", value: "noindex, nofollow, noarchive" }] : []),33];3435const config: NextConfig = {36 // The preview build lives apart so that it can never be started by mistake as the production build.37 distDir: preview ? ".next-preview" : ".next",38 // Server-only packages that must be loaded by Node, not bundled.39 serverExternalPackages: ["@simplewebauthn/server"],40 poweredByHeader: false,41 compress: false, // the gateway compresses42 reactStrictMode: true,43 async headers() {44 return [45 // Imported figures and media answer with their own, stricter policy (set by the route handlers).46 { source: "/((?!media/|contenu/|diapositives/|admin/apercu/media/|admin/apercu/contenu/|admin/apercu/diapositives/).*)", headers: [{ key: "Content-Security-Policy", value: csp }, ...common] },47 { source: "/(media|contenu|diapositives)/:path*", headers: common },48 { source: "/admin/apercu/(media|contenu|diapositives)/:path*", headers: common },49 // The studio is private: never indexed, never stored by a cache, whatever a page or a handler forgets to say.50 { source: "/admin/:path*", headers: [{ key: "X-Robots-Tag", value: "noindex, nofollow, noarchive" }, { key: "Cache-Control", value: "private, no-store" }] },51 { source: "/admin", headers: [{ key: "X-Robots-Tag", value: "noindex, nofollow, noarchive" }, { key: "Cache-Control", value: "private, no-store" }] },52 ];53 },54};55export default config;56