Feat/rid of env (#443)

* Get rid of VITE_API_BASE_URL

* wip

* wip
This commit is contained in:
Hoan Luu Huu
2024-07-15 19:58:22 +07:00
committed by GitHub
parent dcdc2c0808
commit 2c390715d8
2 changed files with 7 additions and 3 deletions

4
.env
View File

@@ -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

View File

@@ -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;