const createNextIntlPlugin = require('next-intl/plugin'); const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts'); /** @type {import('next').NextConfig} */ const nextConfig = { // Move the dev-only build/error indicator out of the bottom-left default, where // it sits on top of the mobile bottom nav. (Dev only — never shipped to prod.) devIndicators: { position: 'top-left', }, // next-auth v5 beta ships as ESM with an internal circular dependency that leaves // React = null inside webpack's static-generation workers. Forcing transpilation // makes webpack process it as CJS in the same pass as the app, which resolves the // initialization order and prevents the React-null crash during build. transpilePackages: ['next-auth', '@auth/core'], images: { unoptimized: false, remotePatterns: [ { protocol: 'https', hostname: '*.amazonaws.com', pathname: '/**', }, // Cloudflare R2 — where all content images actually live (S3_PUBLIC_URL, // bucket revampit-media). Without this the optimizer rejects R2 URLs, // which is why `unoptimized` was scattered across image components. { protocol: 'https', hostname: '*.r2.dev', pathname: '/**', }, ], }, async rewrites() { // Deck URLs (`/presentations/`) are intentionally NOT rewritten to the // static index.html here: an `afterFiles` rewrite is matched BEFORE dynamic // app routes, which would bypass the access gate. Instead the route handler // `src/app/presentations/[slug]/route.ts` owns the URL — it enforces each // deck's `audience` and serves the file from public/ (same fs pattern the // blog uses for content/posts). Nested assets + /_assets stay static. return []; }, async headers() { // Security headers on every response. Shape follows the fleet reference // implementation, aoz-begleitung/next.config.js. Everything in this list is // inert for rendering: it constrains sniffing, framing, referrer detail, // transport and device APIs — never what a page is allowed to load. const securityHeaders = [ { key: 'X-Content-Type-Options', value: 'nosniff' }, { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' }, // SAMEORIGIN, not DENY: nothing here is meant to be embedded on another // site (no embed route, no OG/preview frame), and the two