From 276e9a5b251949afe018805a355c7a7a84da02eb Mon Sep 17 00:00:00 2001 From: yushen Date: Sun, 15 Feb 2026 06:42:30 +0800 Subject: [PATCH] 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 --- apps/web/next.config.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 8250f626..6d192d42 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -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",