From efbe91ce149a510ae18f4d3c9c804d467f8156f2 Mon Sep 17 00:00:00 2001 From: Felipe Cardoso Date: Tue, 6 Jan 2026 09:22:44 +0100 Subject: [PATCH] fix(frontend): use configurable backend URL in Next.js rewrite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rewrite was using 'http://backend:8000' which only resolves inside Docker network. When running Next.js locally (npm run dev), the hostname 'backend' doesn't exist, causing ENOTFOUND errors. Now uses NEXT_PUBLIC_API_BASE_URL env var with fallback to localhost:8000 for local development. In Docker, set NEXT_PUBLIC_API_BASE_URL=http://backend:8000. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- frontend/next.config.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/next.config.ts b/frontend/next.config.ts index 5b863a3..5e37e82 100755 --- a/frontend/next.config.ts +++ b/frontend/next.config.ts @@ -74,12 +74,14 @@ const nextConfig: NextConfig = { ]; }, - // Ensure we can connect to the backend in Docker + // Proxy API requests to backend + // Use NEXT_PUBLIC_API_BASE_URL for the destination (defaults to localhost for local dev) async rewrites() { + const backendUrl = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8000'; return [ { source: '/api/:path*', - destination: 'http://backend:8000/api/:path*', + destination: `${backendUrl}/api/:path*`, }, ]; },