From cd5d8ba9fba862d71d7e7c419fe9d9d4d20b4dfc Mon Sep 17 00:00:00 2001 From: manuel_boissiere Date: Sat, 16 May 2026 10:39:40 +0100 Subject: [PATCH] Set BACKEND_URL on frontend so /api/auth/* reaches backend container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Next.js rewrite in frontend/next.config.ts is: destination: `${process.env.BACKEND_URL || "http://localhost:3501"}/api/auth/:path*` The localhost fallback is correct for native dev (running `bun dev` directly on the host alongside the backend), but in docker compose the frontend service's localhost resolves to itself — not to the backend container — so /api/auth/* gets proxied to nothing useful and Better Auth requests 404. Set BACKEND_URL to the backend service hostname so the rewrite lands on the right container. The Docker bridge already resolves "backend" to the backend service. Repro: `make dev`, open http://localhost:3500/auth/sign-up, submit. Network tab: POST /api/auth/sign-up/email returns 404 (rewrite hits frontend container's own port 3501, which isn't bound). After: same flow returns 200 and the user is created. --- docker-compose.dev.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index b02a2ca..4eefa7e 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -45,6 +45,7 @@ services: - ./frontend/public:/app/public environment: NEXT_PUBLIC_AUTH_URL: http://localhost:3500 + BACKEND_URL: http://backend:3501 depends_on: - backend