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:
parent
4dba1cfdf0
commit
276e9a5b25
1 changed files with 10 additions and 10 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue