multica/apps/web/next.config.ts
yushen 276e9a5b25 fix(web): defer MULTICA_API_URL check to runtime in next.config
Move the env var read into the rewrites function so `next build`
succeeds without MULTICA_API_URL set (it is only needed at runtime).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 06:42:30 +08:00

32 lines
727 B
TypeScript

import type { NextConfig } from "next";
const nextConfig: NextConfig = {
transpilePackages: ["@multica/ui", "@multica/store", "@multica/hooks", "@multica/sdk"],
rewrites: async () => {
const apiUrl = process.env.MULTICA_API_URL;
if (!apiUrl) return [];
return [
{
source: "/api/:path*",
destination: `${apiUrl}/api/:path*`,
},
];
},
headers: async () => [
{
source: "/sw.js",
headers: [
{
key: "Cache-Control",
value: "no-cache, no-store, must-revalidate",
},
{
key: "Content-Type",
value: "application/javascript; charset=utf-8",
},
],
},
],
};
export default nextConfig;