SPB Git forge
15commits 1branches 0releases
29.7 MBsize
maindefault branch
10 days agolast push
TypeScript 36.3% Python 31.8% Go 18% JavaScript 9.8% Shell 1.9% SQL 1.4% CSS 0.5%
2.4 KB · 61 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` 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}1516// Browser code always calls relative `/api/...`; in dev Next proxies it to the FastAPI service (or the mock).17// In production the edge Caddy routes `/api/*` straight to the API, so this rewrite is a fallback only.18const API_URL = process.env.API_URL ?? 'http://127.0.0.1:8352';1920const nextConfig: NextConfig = {21  reactStrictMode: true,22  poweredByHeader: false,23  output: 'standalone',24  allowedDevOrigins: ['127.0.0.1', 'localhost'],25  outputFileTracingRoot: path.resolve(__dirname, '../..'),26  experimental: {27    optimizePackageImports: ['lucide-react'],28  },29  async rewrites() {30    return [{ source: '/api/:path*', destination: `${API_URL}/api/:path*` }];31  },32  async headers() {33    const PUBLIC_CACHE = { key: 'Cache-Control', value: 'public, s-maxage=60, stale-while-revalidate=300' };34    const NO_STORE = { key: 'Cache-Control', value: 'private, no-store' };35    return [36      {37        source: '/(.*)',38        headers: [39          { key: 'X-Content-Type-Options', value: 'nosniff' },40          { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },41          { key: 'X-Frame-Options', value: 'SAMEORIGIN' },42          { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },43          { key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains' },44        ],45      },46      { source: '/country/:path*', headers: [PUBLIC_CACHE] },47      { source: '/internet/:path*', headers: [PUBLIC_CACHE] },48      { source: '/asn/:path*', headers: [PUBLIC_CACHE] },49      { source: '/service/:path*', headers: [PUBLIC_CACHE] },50      { source: '/event/:path*', headers: [PUBLIC_CACHE] },51      { source: '/history/:path*', headers: [PUBLIC_CACHE] },52      { source: '/history', headers: [PUBLIC_CACHE] },53      { source: '/api/:path*', headers: [NO_STORE] },54      { source: '/admin/:path*', headers: [NO_STORE] },55      { source: '/admin', headers: [NO_STORE] },56    ];57  },58};5960export default nextConfig;61