import { withFontCopy } from '@lumina/island/tools/font-copy-plugin'; import { withIconSprite } from '@lumina/island/tools/icon-sprite-plugin'; import type { NextConfig } from 'next'; import { API_PROXY_MAX_BODY, API_PROXY_PATH, API_PROXY_TIMEOUT_MS, } from './src/constants'; import { adminApiInternalUrl } from './src/env/env.config'; // Fonts and the icon sprite keep fixed names (0011, 0012); Next serves public/ with max-age=0. const immutable = [ { key: 'Cache-Control', value: 'public, max-age=31536000, immutable' }, ]; // The panel is never framed, never indexed, and never sends full URLs to other sites. const security = [ { key: 'Content-Security-Policy', value: "frame-ancestors 'none'" }, { key: 'X-Frame-Options', value: 'DENY' }, { key: 'X-Content-Type-Options', value: 'nosniff' }, { key: 'Referrer-Policy', value: 'same-origin' }, { key: 'X-Robots-Tag', value: 'noindex, nofollow' }, ]; const nextConfig: NextConfig = { // Metadata always in (0054). htmlLimitedBots: /.*/, experimental: { proxyTimeout: API_PROXY_TIMEOUT_MS, proxyClientMaxBodySize: API_PROXY_MAX_BODY, }, // Workspace packages export TypeScript source, so Next.js compiles them. transpilePackages: [ '@lumina/garden-roof', '@lumina/integrations', '@lumina/island', '@lumina/libs', '@lumina/tools', ], // The browser calls the admin API on this site's origin (`/api/v1/admin/…`), proxied to // admin-api, so there is no CORS and the session cookies are this site's (0061). No service // worker or manifest: the panel isn't installable (0062). async rewrites() { return [ { source: `${API_PROXY_PATH}/:path*`, destination: `${adminApiInternalUrl()}/:path*`, }, ]; }, async headers() { return [ { source: '/:path*', headers: security }, { source: '/fonts/:path*', headers: immutable }, { source: '/icons/:path*', headers: immutable }, ]; }, async redirects() { return [{ source: '/', destination: '/health', permanent: false }]; }, }; // On next dev and next build, island's plugins write the fonts and icon sprite into public/ // under their fixed names, with no hash (0012). export default withIconSprite(withFontCopy(nextConfig));