diff --git a/entrypoint.sh b/entrypoint.sh index 990ffa9..d6688e0 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,9 +9,15 @@ API_PORT="${API_PORT:-3000}" API_VERSION="${API_VERSION:-v1}" API_BASE_URL=${API_BASE_URL:-http://$PUBLIC_IPV4:$API_PORT/$API_VERSION} +# Default to "false" if not set +DISABLE_LCR=${DISABLE_LCR:-false} +DISABLE_JAEGER_TRACING=${DISABLE_JAEGER_TRACING:-false} +DISABLE_CUSTOM_SPEECH=${DISABLE_CUSTOM_SPEECH:-false} +ENABLE_FORGOT_PASSWORD=${ENABLE_FORGOT_PASSWORD:-false} + # Serialize window global to provide the API URL to static frontend dist # This is declared and utilized in the web app: src/api/constants.ts -SCRIPT_TAG="" +SCRIPT_TAG="" sed -i -e "\@@i\ $SCRIPT_TAG" ./dist/index.html # Start the frontend web app static server diff --git a/src/api/constants.ts b/src/api/constants.ts index 5a0123a..09b3750 100644 --- a/src/api/constants.ts +++ b/src/api/constants.ts @@ -13,6 +13,10 @@ import type { /** The API url is constructed with the docker containers `ip:port` */ interface JambonzWindowObject { API_BASE_URL: string; + DISABLE_LCR: string; + DISABLE_JAEGER_TRACING: string; + DISABLE_CUSTOM_SPEECH: string; + ENABLE_FORGOT_PASSWORD: string; } declare global { @@ -29,24 +33,23 @@ export const API_BASE_URL = export const DEV_BASE_URL = import.meta.env.VITE_DEV_BASE_URL; /** Disable custom speech vendor*/ -export const DISABLE_CUSTOM_SPEECH: boolean = JSON.parse( - import.meta.env.VITE_DISABLE_CUSTOM_SPEECH || "false" -); +export const DISABLE_CUSTOM_SPEECH: boolean = + window.JAMBONZ?.DISABLE_CUSTOM_SPEECH === "true" || + JSON.parse(import.meta.env.VITE_DISABLE_CUSTOM_SPEECH || "false"); /** Enable Forgot Password */ -export const ENABLE_FORGOT_PASSWORD: boolean = JSON.parse( - import.meta.env.VITE_ENABLE_FORGOT_PASSWORD || "false" -); - +export const ENABLE_FORGOT_PASSWORD: boolean = + window.JAMBONZ?.ENABLE_FORGOT_PASSWORD === "true" || + JSON.parse(import.meta.env.VITE_ENABLE_FORGOT_PASSWORD || "false"); /** Disable Lcr */ -export const DISABLE_LCR: boolean = JSON.parse( - import.meta.env.VITE_APP_LCR_DISABLED || "false" -); +export const DISABLE_LCR: boolean = + window.JAMBONZ?.DISABLE_LCR === "true" || + JSON.parse(import.meta.env.VITE_APP_LCR_DISABLED || "false"); /** Disable jaeger tracing */ -export const DISABLE_JAEGER_TRACING: boolean = JSON.parse( - import.meta.env.VITE_APP_JAEGER_TRACING_DISABLED || "false" -); +export const DISABLE_JAEGER_TRACING: boolean = + window.JAMBONZ?.DISABLE_JAEGER_TRACING === "true" || + JSON.parse(import.meta.env.VITE_APP_JAEGER_TRACING_DISABLED || "false"); /** TCP Max Port */ export const TCP_MAX_PORT = 65535;