From 07185dd39f5a4adaae08b7a6fc98430d491123ae Mon Sep 17 00:00:00 2001 From: "railway-app[bot]" <68434857+railway-app[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 03:29:28 +0000 Subject: [PATCH] fix: route production API calls to public backend URL --- frontend/src/lib/api.ts | 8 +++++++- frontend/src/lib/intelligence/client.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 150eec1..a205378 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -43,13 +43,19 @@ interface ApiQueryResult { available: boolean; } +const PRODUCTION_API_URL = "https://thesphere-production-4aea.up.railway.app"; + function getApiBaseUrl() { if (process.env.NEXT_PUBLIC_API_BASE_URL) { return process.env.NEXT_PUBLIC_API_BASE_URL; } if (typeof window !== "undefined") { - return `${window.location.protocol}//${window.location.hostname}:8000`; + const host = window.location.hostname; + if (host !== "localhost" && host !== "127.0.0.1") { + return PRODUCTION_API_URL; + } + return `${window.location.protocol}//${host}:8000`; } return "http://localhost:8000"; diff --git a/frontend/src/lib/intelligence/client.ts b/frontend/src/lib/intelligence/client.ts index 41fee44..b7b1ce8 100644 --- a/frontend/src/lib/intelligence/client.ts +++ b/frontend/src/lib/intelligence/client.ts @@ -82,6 +82,8 @@ export interface IntelligenceClientOptions { signal?: AbortSignal; } +const PRODUCTION_API_URL = "https://thesphere-production-4aea.up.railway.app"; + function resolveBaseUrl(explicit: string | undefined): string { if (explicit) { return explicit.replace(/\/$/, ""); @@ -90,7 +92,11 @@ function resolveBaseUrl(explicit: string | undefined): string { return process.env.NEXT_PUBLIC_API_BASE_URL.replace(/\/$/, ""); } if (typeof window !== "undefined") { - return `${window.location.protocol}//${window.location.hostname}:8000`; + const host = window.location.hostname; + if (host !== "localhost" && host !== "127.0.0.1") { + return PRODUCTION_API_URL; + } + return `${window.location.protocol}//${host}:8000`; } return "http://localhost:8000"; }