From 2115f406b86d1f45b8873307aa213a2b50730ee8 Mon Sep 17 00:00:00 2001 From: ypratama Date: Fri, 28 Aug 2026 11:11:53 +0700 Subject: [PATCH] Fix: use INTERNAL_API_URL for runtime backend URL (NEXT_PUBLIC_ is baked at build time) --- src/app/api/[...route]/route.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/api/[...route]/route.ts b/src/app/api/[...route]/route.ts index 9d82060..25e21e0 100644 --- a/src/app/api/[...route]/route.ts +++ b/src/app/api/[...route]/route.ts @@ -27,8 +27,9 @@ async function handleProxy(req: NextRequest, { params }: { params: Promise<{ rou const url = new URL(req.url); - // Force ALL traffic to go through our own Centralized Proxy Server (Express Backend) - const localBase = process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:3001'; + // INTERNAL_API_URL is read at RUNTIME (not baked at build time like NEXT_PUBLIC_*) + // This allows Docker Swarm / Portainer to set the backend URL dynamically + const localBase = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:3001'; const destinationUrl = `${localBase}/api/${route}${url.search}`; // Prepare headers