diff --git a/src/api/client.ts b/src/api/client.ts index 73713e2..2a1dc0f 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -28,7 +28,8 @@ interface RequestOptions { } function buildUrl(path: string, params?: ListParams): string { - const url = new URL(path, BASE_URL) + const base = BASE_URL || (typeof location !== 'undefined' ? location.origin : 'http://localhost') + const url = new URL(path, base) if (params) { for (const [key, value] of Object.entries(params)) { if (value !== undefined && value !== null && value !== '') {