From 89bedb8f5c92b41c76b1f566cb1ae88d747212ac Mon Sep 17 00:00:00 2001 From: Jiang Bohan Date: Tue, 31 Mar 2026 16:53:32 +0800 Subject: [PATCH] feat(web): support REMOTE_API_URL env for proxying to remote backend - Load root .env in next.config.ts so REMOTE_API_URL is available - Default fallback remains localhost:8080 (no impact on existing setups) - Add REMOTE_API_URL to .env.example with documentation --- .env.example | 4 ++++ apps/web/next.config.ts | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index e627d3f9..bfa38ae7 100644 --- a/.env.example +++ b/.env.example @@ -44,3 +44,7 @@ FRONTEND_PORT=3000 FRONTEND_ORIGIN=http://localhost:3000 NEXT_PUBLIC_API_URL=http://localhost:8080 NEXT_PUBLIC_WS_URL=ws://localhost:8080/ws + +# Remote API (optional) — set to proxy local frontend to a remote backend +# Leave empty to use local backend (localhost:8080) +# REMOTE_API_URL=https://multica-api.copilothub.ai diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 444f4090..28323d41 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -1,6 +1,11 @@ import type { NextConfig } from "next"; +import { config } from "dotenv"; +import { resolve } from "path"; -const remoteApiUrl = process.env.REMOTE_API_URL ?? "https://multica-api.copilothub.ai"; +// Load root .env so REMOTE_API_URL is available to next.config.ts +config({ path: resolve(__dirname, "../../.env") }); + +const remoteApiUrl = process.env.REMOTE_API_URL || "http://localhost:8080"; const nextConfig: NextConfig = { async rewrites() {