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