Skip to content

Fix frontend API URL to use internal backend DNS#1

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

Fix frontend API URL to use internal backend DNS#1
railway-app[bot] wants to merge 1 commit intohosting-railwayfrom
railway/code-change-1phHQK

Conversation

@railway-app
Copy link
Copy Markdown

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

Problem

The getApiBaseUrl() function in frontend/src/lib/api.ts fell back to window.location.hostname:8000 when NEXT_PUBLIC_API_BASE_URL was unset. In production this constructed http://reliable-caring-production-f609.up.railway.app:8000, which is the frontend's own public hostname on the wrong port — the backend is not reachable there.

Solution

Replaced the window.location fallback with a server-side branch that returns process.env.SPHERE_BACKEND_URL (matching the pattern already used in _lib/upstream.ts) or hard-falls back to http://thesphere.railway.internal:8000 — the backend's Railway-internal DNS address. Client-side (browser) requests in local development still fall through to http://localhost:8000. The NEXT_PUBLIC_API_BASE_URL override continues to take highest priority for any explicit configuration.

Changes

  • Modified frontend/src/lib/api.ts

Generated by Railway

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