import type { NextConfig } from "next"; const nextConfig: NextConfig = { reactStrictMode: true, output: "standalone", // In dev (no Caddy) Next.js itself proxies /api/* and /health to the backend // so the browser can use same-origin relative URLs. // In prod Caddy intercepts these paths before they reach Next.js, // so these rewrites are effectively a no-op there. async rewrites() { const backend = process.env.BACKEND_URL ?? "http://localhost:8000"; return [ { source: "/api/:path*", destination: `${backend}/api/:path*` }, { source: "/health", destination: `${backend}/health` }, ]; }, }; export default nextConfig;