Skip to content

Use NEXT_PUBLIC env vars for API URLs without hardcoding#4

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

Use NEXT_PUBLIC env vars for API URLs without hardcoding#4
railway-app[bot] wants to merge 1 commit intohosting-railwayfrom
railway/code-change-fDu_bw

Conversation

@railway-app
Copy link
Copy Markdown

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

Problem

The frontend hardcoded http://localhost:8000 as the default in the Dockerfile ARG declarations, meaning the baked-in build artifact always pointed at localhost regardless of what Railway injected. Additionally, NEXT_PUBLIC_API_URL and NEXT_PUBLIC_WS_URL were not recognised as fallback sources in either api.ts or intelligence/client.ts, and there was no getWebSocketUrl() helper for deriving WebSocket URLs from the configured API base.

Solution

Removed the =http://localhost:8000 and =ws://localhost:8000 defaults from the Dockerfile ARGs so Railway-injected values are never silently overridden. Replaced NEXT_PUBLIC_WS_BASE_URL with the correctly named NEXT_PUBLIC_WS_URL and added NEXT_PUBLIC_API_URL as a recognised ARG/ENV. Updated getApiBaseUrl() in api.ts and resolveBaseUrl() in intelligence/client.ts to check NEXT_PUBLIC_API_BASE_URL first, then NEXT_PUBLIC_API_URL, then fall back to the hostname-derived localhost. Added getWebSocketUrl() to client.ts that honours NEXT_PUBLIC_WS_URL and derives wss:///ws:// from the resolved API URL when the env var is absent.

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:34 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