SPB Git forge
28commits 1branches 0releases
7.7 MBsize
maindefault branch
10 days agolast push
Python 66.3% TypeScript 22.7% JavaScript 8.6% HTML 1.4% CSS 0.7%
2.4 KB · 62 lines typescript
Raw Blame History
1import type { NextConfig } from 'next';2import { existsSync } from 'node:fs';3import path from 'node:path';45// Monorepo: the single `.env` lives at the repository root; Next only reads the app directory by default.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// Dev: FastAPI (or qa/mock-api.mjs) on :8371. Production sets API_URL=http://127.0.0.1:8361 in the mld manifest.17const API_URL = (process.env.API_URL ?? 'http://127.0.0.1:8371').replace(/\/$/, '');1819const nextConfig: NextConfig = {20  // NEXT_DIST_DIR lets parallel dev servers / builds use separate output dirs (default .next).21  distDir: process.env.NEXT_DIST_DIR || '.next',22  reactStrictMode: true,23  poweredByHeader: false,24  allowedDevOrigins: ['127.0.0.1', 'localhost'],25  outputFileTracingRoot: path.resolve(__dirname, '../..'),26  experimental: {27    optimizePackageImports: ['lucide-react'],28  },29  // Browser-side fetches go to the same origin; the FastAPI service is loopback-only.30  async rewrites() {31    return [32      { source: '/api/v1/:path*', destination: `${API_URL}/api/v1/:path*` },33      { source: '/health', destination: `${API_URL}/health` },34    ];35  },36  async headers() {37    const PUBLIC_CACHE = { key: 'Cache-Control', value: 'public, s-maxage=120, stale-while-revalidate=1800' };38    const NO_STORE = { key: 'Cache-Control', value: 'private, no-store' };39    return [40      {41        source: '/(.*)',42        headers: [43          { key: 'X-Content-Type-Options', value: 'nosniff' },44          { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },45          { key: 'X-Frame-Options', value: 'SAMEORIGIN' },46          { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },47          { key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains' },48        ],49      },50      { source: '/company/:path*', headers: [PUBLIC_CACHE] },51      { source: '/industry/:path*', headers: [PUBLIC_CACHE] },52      { source: '/country/:path*', headers: [PUBLIC_CACHE] },53      { source: '/api/:path*', headers: [NO_STORE] },54      { source: '/live', headers: [NO_STORE] },55      { source: '/watchlist', headers: [NO_STORE] },56      { source: '/admin/:path*', headers: [NO_STORE] },57    ];58  },59};6061export default nextConfig;62