Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/lib/intelligence/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(/\/$/, "");
Expand All @@ -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";
}
Expand Down