Skip to content

Fix frontend to use public backend URL instead of localhost#2

Open
railway-app[bot] wants to merge 1 commit intohosting-railwayfrom
railway/code-change-9Fh2s-
Open

Fix frontend to use public backend URL instead of localhost#2
railway-app[bot] wants to merge 1 commit intohosting-railwayfrom
railway/code-change-9Fh2s-

Conversation

@railway-app
Copy link
Copy Markdown

@railway-app railway-app Bot commented Apr 28, 2026

Problem

The frontend Dockerfile declared ARG NEXT_PUBLIC_API_BASE_URL=http://localhost:8000, which baked localhost into the Next.js bundle at build time. Railway doesn't pass build args, so every production deploy shipped with localhost:8000 hardcoded — causing the browser to call itself instead of the backend, resulting in the "BACKBONE OFFLINE" state.

Solution

Removed the localhost defaults from the Dockerfile ARG declarations so the env vars are empty at build time. Updated getApiBaseUrl() in api.ts and resolveBaseUrl() in intelligence/client.ts to detect at runtime whether the browser is on a non-localhost host and, if so, return the public backend URL (https://thesphere-production-4aea.up.railway.app). Local development continues to work unchanged — localhost and 127.0.0.1 still fall back to port 8000 on the same machine.

Changes

  • Modified frontend/src/lib/api.ts
  • Modified frontend/src/lib/intelligence/client.ts
  • Modified infra/docker/frontend.Dockerfile

Generated by Railway

@railway-app railway-app Bot temporarily deployed to pacific-grace / production April 28, 2026 03:21 Inactive
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.

0 participants