Fix: use INTERNAL_API_URL for runtime backend URL (NEXT_PUBLIC_ is baked at build time)

This commit is contained in:
ypratama committed 2026-08-28 11:11:53 +07:00
1 parent 60cd973dc8
commit 2115f406b8
1 file changed
+3 -2
+3 -2
View File
@@ -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