import type { NextConfig } from "next"; // Everything under /api is the backend (docs/APP-1.0-PLAN.md §1). On a server nginx sends it // there; in development (and when Next is reached directly) this rewrite does. const api = (process.env.APP_API_URL || "http://127.0.0.1:5400").replace(/\/+$/, ""); const nextConfig: NextConfig = { poweredByHeader: false, transpilePackages: ["@crosscode/ui"], async rewrites() { return [{ source: "/api/:path*", destination: `${api}/api/:path*` }]; }, async headers() { // Public content is indexed (ROADMAP-v3 §11); the member's own pages, the admin and every // prayer page never are (APP-1.0-PLAN §4, §11). const common = [ { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" }, { key: "X-Content-Type-Options", value: "nosniff" }, ]; const noindex = { key: "X-Robots-Tag", value: "noindex, nofollow" }; const never = ["/admin", "/admin/:path*", "/me", "/me/:path*", "/prayer", "/prayer/:path*", "/auth/:path*", "/offline"]; return [ { source: "/:path*", headers: common }, ...never.map((source) => ({ source, headers: [noindex] })), // The service worker is checked for updates on every visit (§2). { source: "/sw.js", headers: [{ key: "Cache-Control", value: "no-cache" }, { key: "Service-Worker-Allowed", value: "/" }] }, ]; }, }; export default nextConfig;