/** @type {import('next').NextConfig} */ import { toRewrites } from "./scripts/routes.mjs"; // STATIC_EXPORT=1 switches to the static bundle for Cloudflare Pages (output: // export, no rewrites — pages resolve at clean paths / via the generated // out/_redirects). Unset = normal // dev + preview: `next dev` serves the clean URLs via the rewrites below and // the /api/mock route is live. Local testing is unchanged. const STATIC = process.env.STATIC_EXPORT === "1"; const nextConfig = { reactStrictMode: true, // `npm run local:lan` serves the dev site to phones/foldables on the LAN; Next // blocks dev asset requests from origins it wasn't started on unless listed. allowedDevOrigins: ["192.168.*.*", "10.*.*.*", "172.16.*.*", "*.local"], ...(STATIC ? { output: "export", trailingSlash: true } : {}), images: { unoptimized: true, remotePatterns: [] }, ...(STATIC ? {} : { async rewrites() { return { // Proxy the mock API to the standalone dev mock server (started by // `npm run local`). Not present in the static export. beforeFiles: [ { source: "/api/mock/:path*", destination: "http://127.0.0.1:4100/api/mock/:path*" }, ...toRewrites(), ], }; }, }), }; export default nextConfig;