import type { NextConfig } from "next"; // Everything under /api is the backend (docs/WEBSITE-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.WEBSITE_API_URL || "http://127.0.0.1:5300").replace(/\/+$/, ""); const nextConfig: NextConfig = { poweredByHeader: false, transpilePackages: ["@crosscode/ui"], async rewrites() { return [{ source: "/api/:path*", destination: `${api}/api/:path*` }]; }, async headers() { // The public site is indexed (ROADMAP-v3 §11); the admin and shared previews never are. 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" }; return [ { source: "/:path*", headers: common }, { source: "/admin/:path*", headers: [noindex] }, { source: "/admin", headers: [noindex] }, { source: "/preview/:path*", headers: [noindex] }, { source: "/auth/:path*", headers: [noindex] }, ]; }, }; export default nextConfig;