From 78543d71873985757dd5fb2f4ea694c5954c529c Mon Sep 17 00:00:00 2001 From: Naiyuan Qing <145280634+NevilleQingNY@users.noreply.github.com> Date: Thu, 26 Feb 2026 15:35:53 +0800 Subject: [PATCH] fix(web): remove API proxy, use direct backend requests - Remove Next.js rewrites proxy configuration - Use NEXT_PUBLIC_API_URL for direct API requests - Fixes ECONNRESET errors from proxy failures Co-Authored-By: Claude Opus 4.5 --- apps/web/.env.development | 3 +++ apps/web/lib/constant.ts | 4 ++-- apps/web/next.config.ts | 11 +---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/web/.env.development b/apps/web/.env.development index d2f86570..8de8c755 100644 --- a/apps/web/.env.development +++ b/apps/web/.env.development @@ -1 +1,4 @@ +# Frontend direct API request (browser-accessible) +NEXT_PUBLIC_API_URL=https://api-dev.copilothub.ai +# Core package still uses this MULTICA_API_URL=https://api-dev.copilothub.ai diff --git a/apps/web/lib/constant.ts b/apps/web/lib/constant.ts index 692db158..c6b5389b 100644 --- a/apps/web/lib/constant.ts +++ b/apps/web/lib/constant.ts @@ -1,2 +1,2 @@ -// API Host -export const API_HOST = process.env.NEXT_PUBLIC_API_HOST || ''; +// API Host - direct request to backend (no proxy) +export const API_HOST = process.env.NEXT_PUBLIC_API_URL || process.env.NEXT_PUBLIC_API_HOST || ''; diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 6d192d42..dc354f3f 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -2,16 +2,7 @@ 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*`, - }, - ]; - }, + // Removed rewrites proxy - frontend requests API directly via NEXT_PUBLIC_API_URL headers: async () => [ { source: "/sw.js",