SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
2.4 KB · 60 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.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 nextConfig: NextConfig = {17  reactStrictMode: true,18  poweredByHeader: false,19  agentRules: false,20  // Workspace packages are consumed as TypeScript sources.21  transpilePackages: ['@rareindex/shared', '@rareindex/database', '@rareindex/taxonomy', '@rareindex/connectors', '@rareindex/ai', '@rareindex/notify'],22  serverExternalPackages: ['postgres', 'pino', 'cheerio', 'pg-boss', '@anthropic-ai/sdk', 'openai'],23  // Public API: /api/v1/* is proxied to the Fastify service (apps/api) so one public host serves web + API.24  async rewrites() {25    const api = process.env.RI_API_URL ?? `http://127.0.0.1:${process.env.API_PORT ?? 8211}`;26    return [{ source: '/api/v1/:path*', destination: `${api}/v1/:path*` }];27  },28  images: {29    remotePatterns: [{ protocol: 'https', hostname: '**' }],30    formats: ['image/avif', 'image/webp'],31  },32  // Static pages query a large database; give the prerender workers room (default 60 s).33  staticPageGenerationTimeout: 240,34  experimental: {35    optimizePackageImports: ['lucide-react'],36    // The image cache core is shared with the worker (workers/image-processing/core.ts) via a relative re-export.37    externalDir: true,38    // Workspace packages use NodeNext-style `./file.js` imports that resolve to .ts sources.39    // Turbopack does not rewrite these outside the app root, so the app is built with webpack40    // (`next dev/build --webpack`) where extensionAlias handles the mapping.41    extensionAlias: { '.js': ['.ts', '.tsx', '.js'], '.mjs': ['.mts', '.mjs'] },42  },43  outputFileTracingRoot: path.resolve(__dirname, '../..'),44  async headers() {45    return [46      {47        source: '/(.*)',48        headers: [49          { key: 'X-Content-Type-Options', value: 'nosniff' },50          { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },51          { key: 'X-Frame-Options', value: 'SAMEORIGIN' },52          { key: 'Permissions-Policy', value: 'camera=(self), microphone=(), geolocation=()' },53        ],54      },55    ];56  },57};5859export default nextConfig;60