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>
This commit is contained in:
yushen 2026-02-15 06:42:30 +08:00
parent 4dba1cfdf0
commit 276e9a5b25

View file

@ -1,17 +1,17 @@
import type { NextConfig } from "next";
if (!process.env.MULTICA_API_URL) {
throw new Error("MULTICA_API_URL is required");
}
const nextConfig: NextConfig = {
transpilePackages: ["@multica/ui", "@multica/store", "@multica/hooks", "@multica/sdk"],
rewrites: async () => [
{
source: "/api/:path*",
destination: `${process.env.MULTICA_API_URL}/api/:path*`,
},
],
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",