import os from 'os'; function getPermittedDevOrigins() { const origins = new Set([ 'localhost', '127.0.0.1', '0.0.0.0', '*.local', '*.lan', '*.internal', '*.home', '*.nip.io', '*.sslip.io', ]); try { // 1. Automatically register all host network interfaces (IPv4 & IPv6) const interfaces = os.networkInterfaces(); for (const name of Object.keys(interfaces)) { for (const iface of interfaces[name] || []) { if (iface.address) { origins.add(iface.address); } } } } catch (e) { // ignore } // 2. Pre-permit entire private subnets (192.168.1.0/24, 192.168.0.0/24, 10.0.0.0/24) for (let i = 1; i <= 254; i++) { origins.add(`192.168.1.${i}`); origins.add(`192.168.0.${i}`); origins.add(`10.0.0.${i}`); } return Array.from(origins); } /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, transpilePackages: ['lenis', 'three', 'framer-motion'], allowedDevOrigins: getPermittedDevOrigins(), images: { unoptimized: true, }, experimental: { serverComponentsExternalPackages: ['sharp'], }, async headers() { return [ { source: '/:path*', headers: [ { key: 'Access-Control-Allow-Origin', value: '*' }, { key: 'Access-Control-Allow-Methods', value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT' }, { key: 'Access-Control-Allow-Headers', value: '*' }, ], }, ]; }, async redirects() { try { const fs = await import('fs'); const path = await import('path'); const redirectsPath = path.join(process.cwd(), 'content', 'redirects.json'); if (fs.existsSync(redirectsPath)) { const data = JSON.parse(fs.readFileSync(redirectsPath, 'utf8')); return Array.isArray(data) ? data : []; } } catch (e) { console.warn('Could not load redirects.json', e); } return []; }, }; export default nextConfig;