import type { NextConfig } from "next"; // The marketing landing is served as static files from /public (ported verbatim // from lynkeduppro-landing). These rewrites reproduce the landing's vercel.json // clean-URL routing: "/" is the React marketing home, "/1".."/19" are the static // pages under /public/page. `beforeFiles` lets them override the app router's "/" // (which otherwise redirects to /portal/login). const landingRewrites: { source: string; destination: string }[] = [ { source: "/", destination: "/index.html" }, { source: "/thanks", destination: "/thanks.html" }, { source: "/1", destination: "/page/index.html" }, // "/2".."/19" -> /public/page/.html ...Array.from({ length: 18 }, (_, i) => i + 2).map((n) => ({ source: `/${n}`, destination: `/page/${n}.html`, })), ]; const nextConfig: NextConfig = { // The SDK ships ESM/TS; let Next transpile it. transpilePackages: ["@abe-kap/appshell-sdk"], async rewrites() { // The browser calls the Shell BFF same-origin under /shell (so the HttpOnly // session cookie flows). We deliberately use /shell (NOT /api) to avoid // clobbering the /api/* route handlers (geo, and the founder checkout). const bff = process.env.BFF_ORIGIN ?? "http://localhost:4000"; return { beforeFiles: landingRewrites, afterFiles: [{ source: "/shell/:path*", destination: `${bff}/api/:path*` }], fallback: [], }; }, }; export default nextConfig;