spb/satelliteindex
Public
TypeScript 66.5%
Python 30.9%
JavaScript 1.4%
CSS 0.7%
1import type { NextConfig } from 'next';2import { existsSync } from 'node:fs';3import path from 'node:path';45// Monorepo: a single `.env` lives at the repository root; Next only reads the app directory.6for (const candidate of [path.resolve(process.cwd(), '../../.env'), path.resolve(process.cwd(), '.env')]) {7 if (existsSync(candidate)) {8 try {9 process.loadEnvFile(candidate);10 } catch {11 /* ignore malformed env */12 }13 }14}1516const API_URL = process.env.API_URL ?? 'http://127.0.0.1:8311';1718const nextConfig: NextConfig = {19 reactStrictMode: true,20 poweredByHeader: false,21 allowedDevOrigins: ['127.0.0.1', 'localhost'],22 outputFileTracingRoot: path.resolve(__dirname, '../..'),23 experimental: {24 optimizePackageImports: ['lucide-react', 'three', '@react-three/drei'],25 },26 // Browser-side fetches go to the same origin; the FastAPI service is loopback-only.27 async rewrites() {28 return [29 { source: '/api/v1/:path*', destination: `${API_URL}/api/v1/:path*` },30 { source: '/health', destination: `${API_URL}/health` },31 ];32 },33 async redirects() {34 return [35 { source: '/satellites/:slug((?!facets$)[^/]+)', destination: '/satellite/:slug', permanent: true },36 { source: '/constellations/:slug', destination: '/constellation/:slug', permanent: true },37 { source: '/operators/:slug', destination: '/operator/:slug', permanent: true },38 { source: '/countries/:slug', destination: '/country/:slug', permanent: true },39 ];40 },41 async headers() {42 const PUBLIC_CACHE = { key: 'Cache-Control', value: 'public, s-maxage=600, stale-while-revalidate=3600' };43 const NO_STORE = { key: 'Cache-Control', value: 'private, no-store' };44 return [45 {46 source: '/(.*)',47 headers: [48 { key: 'X-Content-Type-Options', value: 'nosniff' },49 { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },50 { key: 'X-Frame-Options', value: 'SAMEORIGIN' },51 { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },52 { key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains' },53 ],54 },55 { source: '/satellite/:path*', headers: [PUBLIC_CACHE] },56 { source: '/constellation/:path*', headers: [PUBLIC_CACHE] },57 { source: '/operator/:path*', headers: [PUBLIC_CACHE] },58 { source: '/country/:path*', headers: [PUBLIC_CACHE] },59 { source: '/api/:path*', headers: [NO_STORE] },60 { source: '/admin/:path*', headers: [NO_STORE] },61 ];62 },63};6465export default nextConfig;66