PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 9m38s
PR Checks / Backend Smoke (pull_request) Successful in 5s
PR Checks / Build Backend (no push) (pull_request) Successful in 10s
PR Checks / Build Frontend (no push) (pull_request) Successful in 50s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 10s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 3m13s
next.config.js rewrites() bakes its destination into the build (routes-manifest.json), capturing FASTAPI_URL at build time. Because one frontend image is promoted staging->prod, the baked backend host forced every environment to name the backend service identically; staging names it 'backend_stg', so the browser's /api/* calls proxied to the baked 'http://backend' and failed with getaddrinfo ENOTFOUND backend. (SSR was unaffected because lib/api.ts reads FASTAPI_URL at runtime.) Replace the rewrites with route handlers that read FASTAPI_URL per request: - app/api/[...path]/route.ts — transparent proxy for all methods, streams the response, strips hop-by-hop headers, and returns 502 on upstream failure instead of crashing. - app/sitemap.xml/route.ts — proxies the backend sitemap (robots.ts points crawlers here). The same promoted image now adapts to whatever the backend is called in each environment. Verified: production build succeeds with /api/[...path] and /sitemap.xml as dynamic routes and an empty rewrites manifest. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
84 lines
2.1 KiB
JavaScript
84 lines
2.1 KiB
JavaScript
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
// Enable standalone output for Docker
|
|
output: 'standalone',
|
|
|
|
// The /api/* and /sitemap.xml proxies to the FastAPI backend are route
|
|
// handlers (app/api/[...path]/route.ts, app/sitemap.xml/route.ts) rather
|
|
// than rewrites, so the backend host is read from FASTAPI_URL at runtime
|
|
// instead of being baked into the build.
|
|
|
|
// Image optimization
|
|
images: {
|
|
remotePatterns: [
|
|
{ protocol: 'https', hostname: '*.tile.openstreetmap.org' },
|
|
{ protocol: 'https', hostname: 'tile.openstreetmap.org' },
|
|
{ protocol: 'https', hostname: 'cdnjs.cloudflare.com' },
|
|
],
|
|
formats: ['image/avif', 'image/webp'],
|
|
minimumCacheTTL: 31536000,
|
|
},
|
|
|
|
// Performance optimizations
|
|
compiler: {
|
|
// Remove console logs in production
|
|
removeConsole: process.env.NODE_ENV === 'production',
|
|
},
|
|
|
|
// Compression
|
|
compress: true,
|
|
|
|
// React strict mode for better error detection
|
|
reactStrictMode: true,
|
|
|
|
// Power optimizations
|
|
poweredByHeader: false,
|
|
|
|
// Production source maps (disable for smaller bundles)
|
|
productionBrowserSourceMaps: false,
|
|
|
|
// Experimental features for performance
|
|
experimental: {
|
|
// Optimize package imports
|
|
optimizePackageImports: ['chart.js', 'react-chartjs-2', 'leaflet'],
|
|
},
|
|
|
|
// Headers for caching and security
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: '/:path*',
|
|
headers: [
|
|
{
|
|
key: 'X-DNS-Prefetch-Control',
|
|
value: 'on',
|
|
},
|
|
{
|
|
key: 'X-Frame-Options',
|
|
value: 'SAMEORIGIN',
|
|
},
|
|
{
|
|
key: 'X-Content-Type-Options',
|
|
value: 'nosniff',
|
|
},
|
|
{
|
|
key: 'Referrer-Policy',
|
|
value: 'origin-when-cross-origin',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
source: '/favicon.svg',
|
|
headers: [
|
|
{
|
|
key: 'Cache-Control',
|
|
value: 'public, max-age=31536000, immutable',
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
module.exports = nextConfig;
|