Create API base URL utility for all client code

cgen-188cac9c01b24a52894ae0eae6b12663
This commit is contained in:
Builder.io 2025-11-16 10:19:31 +00:00
parent 680747a89b
commit 1ef0cc707b

11
client/lib/api-base.ts Normal file
View file

@ -0,0 +1,11 @@
/**
* Get the API base URL
* Always uses window.location.origin since the API is served from the same origin
* This works for both development (localhost:8080) and production (aethex.dev)
*/
export function getApiBase(): string {
if (typeof window === "undefined") {
return "";
}
return window.location.origin;
}