Skip to content

fix: set BACKEND_URL on frontend so docker-compose auth proxy works#7

Open
TPFLegionaire wants to merge 1 commit into
tinyfish-io:mainfrom
TPFLegionaire:fix/docker-frontend-backend-url
Open

fix: set BACKEND_URL on frontend so docker-compose auth proxy works#7
TPFLegionaire wants to merge 1 commit into
tinyfish-io:mainfrom
TPFLegionaire:fix/docker-frontend-backend-url

Conversation

@TPFLegionaire
Copy link
Copy Markdown

Problem

In make dev, all Better Auth requests fail because the frontend's /api/auth/* rewrite has no way to reach the backend container.

frontend/next.config.ts has:

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 on the same machine). But inside Docker, the frontend container's localhost:3501 resolves to itself, not to the backend service. The frontend doesn't listen on 3501, so the rewrite 404s.

Net effect: sign-up / sign-in / sessions all fail silently from a docker-compose-only environment.

Fix

Set BACKEND_URL: http://backend:3501 on the frontend service in docker-compose.dev.yml. The Docker bridge already resolves backend to the backend service container — no other change needed.

One line.

Verification

Before: POST /api/auth/sign-up/email returns 404.
After: 200 + session cookie + user row in Postgres.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Warning

Rate limit exceeded

@TPFLegionaire has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 51 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5bbe263-8ff7-4ab4-902e-ac2f4938dfed

📥 Commits

Reviewing files that changed from the base of the PR and between 4552227 and cd5d8ba.

📒 Files selected for processing (1)
  • docker-compose.dev.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant