SPB Git

spb/rareindex

Public
2.3 KB · 58 lines typescript
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  experimental: {33    optimizePackageImports: ['lucide-react'],34    // The image cache core is shared with the worker (workers/image-processing/core.ts) via a relative re-export.35    externalDir: true,36    // Workspace packages use NodeNext-style `./file.js` imports that resolve to .ts sources.37    // Turbopack does not rewrite these outside the app root, so the app is built with webpack38    // (`next dev/build --webpack`) where extensionAlias handles the mapping.39    extensionAlias: { '.js': ['.ts', '.tsx', '.js'], '.mjs': ['.mts', '.mjs'] },40  },41  outputFileTracingRoot: path.resolve(__dirname, '../..'),42  async headers() {43    return [44      {45        source: '/(.*)',46        headers: [47          { key: 'X-Content-Type-Options', value: 'nosniff' },48          { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },49          { key: 'X-Frame-Options', value: 'SAMEORIGIN' },50          { key: 'Permissions-Policy', value: 'camera=(self), microphone=(), geolocation=()' },51        ],52      },53    ];54  },55};5657export default nextConfig;58
Files · f5091c0a3f32b0f99bc705c36f16b636342fbdb4
Menu

Theme