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"; }