import type { NextConfig } from "next"; const apiUrl = process.env.API_URL ?? "http://127.0.0.1:8221"; const nextConfig: NextConfig = { reactStrictMode: true, agentRules: false, poweredByHeader: false, transpilePackages: ["@fetcha/core", "@fetcha/db", "@fetcha/email", "@fetcha/providers"], serverExternalPackages: ["pg", "undici", "resend"], // Browser renders + captcha solving can legitimately take 60–120 s: the default 30 s rewrite proxy // timeout would answer 500 before the API replies. experimental: { proxyTimeout: 180_000 }, async rewrites() { // Public API is served on the same domain under /v1/* and forwarded to the Fastify service. return [ { source: "/v1/:path*", destination: `${apiUrl}/v1/:path*` }, { source: "/api/health", destination: `${apiUrl}/health` }, { source: "/api/ready", destination: `${apiUrl}/ready` }, ]; }, async headers() { return [ { source: "/(.*)", headers: [ { key: "X-Content-Type-Options", value: "nosniff" }, { key: "X-Frame-Options", value: "DENY" }, { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" }, { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" }, ], }, ]; }, }; export default nextConfig;