SPB Git forge

spb/countryatlas

Public
20commits 1branches 0releases
268.3 MBsize
maindefault branch
12 days agolast push
TypeScript 57% Python 38.6% JavaScript 3.6% CSS 0.6%
2.1 KB · 57 lines typescript
Raw Blame History
1import type { NextConfig } from 'next';2import { existsSync } from 'node:fs';3import path from 'node:path';45// Monorepo: a single `.env` may live 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:8291';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'],25  },26  // Browser-side fetches go to the same origin; the FastAPI service is loopback-only (ARCHITECTURE §1, §9).27  async rewrites() {28    return [{ source: '/api/v1/:path*', destination: `${API_URL}/api/v1/:path*` }];29  },30  async headers() {31    const PUBLIC_CACHE = { key: 'Cache-Control', value: 'public, s-maxage=600, stale-while-revalidate=3600' };32    const NO_STORE = { key: 'Cache-Control', value: 'private, no-store' };33    return [34      {35        source: '/(.*)',36        headers: [37          { key: 'X-Content-Type-Options', value: 'nosniff' },38          { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },39          { key: 'X-Frame-Options', value: 'SAMEORIGIN' },40          { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },41        ],42      },43      { source: '/countries/:path*', headers: [PUBLIC_CACHE] },44      { source: '/indicators/:path*', headers: [PUBLIC_CACHE] },45      { source: '/rankings/:path*', headers: [PUBLIC_CACHE] },46      { source: '/regions/:path*', headers: [PUBLIC_CACHE] },47      { source: '/compare/:path*', headers: [PUBLIC_CACHE] },48      { source: '/stories/:path*', headers: [PUBLIC_CACHE] },49      { source: '/sources/:path*', headers: [PUBLIC_CACHE] },50      { source: '/api/:path*', headers: [NO_STORE] },51      { source: '/admin/:path*', headers: [NO_STORE] },52    ];53  },54};5556export default nextConfig;57