diff --git a/.env b/.env index aeea59e..fd32a98 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ -VITE_API_BASE_URL=http://127.0.0.1:3000/v1 -VITE_DEV_BASE_URL=http://127.0.0.1:3000/v1 +#VITE_API_BASE_URL=http://127.0.0.1:3000/v1 +#VITE_DEV_BASE_URL=http://127.0.0.1:3000/v1 ## enables choosing units and lisenced account call limits # VITE_APP_ENABLE_ACCOUNT_LIMITS_ALL=true diff --git a/src/api/constants.ts b/src/api/constants.ts index 4e26269..895f3b5 100644 --- a/src/api/constants.ts +++ b/src/api/constants.ts @@ -1,3 +1,4 @@ +import { hasValue } from "src/utils"; import type { Currency, ElevenLabsOptions, @@ -37,8 +38,11 @@ declare global { } /** https://vitejs.dev/guide/env-and-mode.html#env-files */ -export const API_BASE_URL = +const CONFIGURED_API_BASE_URL = window.JAMBONZ?.API_BASE_URL || import.meta.env.VITE_API_BASE_URL; +export const API_BASE_URL = hasValue(CONFIGURED_API_BASE_URL) + ? CONFIGURED_API_BASE_URL + : `${window.location.protocol}//${window.location.hostname}/api/v1`; /** Serves mock API responses from a local dev API server */ export const DEV_BASE_URL = import.meta.env.VITE_DEV_BASE_URL;