Create API base URL utility for all client code
cgen-188cac9c01b24a52894ae0eae6b12663
This commit is contained in:
parent
680747a89b
commit
1ef0cc707b
1 changed files with 11 additions and 0 deletions
11
client/lib/api-base.ts
Normal file
11
client/lib/api-base.ts
Normal 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;
|
||||
}
|
||||
Loading…
Reference in a new issue