SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
2.5 KB · 63 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// Dev: FastAPI on :8331 (see repo .env). Production sets API_URL=http://127.0.0.1:8321 in the mld manifest.17const API_URL = (process.env.API_URL ?? 'http://127.0.0.1:8331').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=300, stale-while-revalidate=3600' };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: '/models/:path*', headers: [PUBLIC_CACHE] },51      { source: '/companies/:path*', headers: [PUBLIC_CACHE] },52      { source: '/papers/:path*', headers: [PUBLIC_CACHE] },53      { source: '/providers/:path*', headers: [PUBLIC_CACHE] },54      { source: '/benchmarks/:path*', headers: [PUBLIC_CACHE] },55      { source: '/hardware/:path*', headers: [PUBLIC_CACHE] },56      { source: '/api/:path*', headers: [NO_STORE] },57      { source: '/admin/:path*', headers: [NO_STORE] },58    ];59  },60};6162export default nextConfig;63