From a02cffaf749c70ab91f4080a25cad00db6d9f987 Mon Sep 17 00:00:00 2001 From: Matt Taylor Date: Thu, 5 Sep 2024 16:28:51 -0500 Subject: [PATCH] use vite.config for home-base url --- src/EXTERNAL_GLOBALS.ts | 1 + src/state/findHomebaseUrl.ts | 3 ++- vite.config.ts | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/EXTERNAL_GLOBALS.ts b/src/EXTERNAL_GLOBALS.ts index a9757be..088a277 100644 --- a/src/EXTERNAL_GLOBALS.ts +++ b/src/EXTERNAL_GLOBALS.ts @@ -2,3 +2,4 @@ declare const __BUILD_TIMESTAMP__: string; declare const __APP_VERSION__: string; declare const __PAP_ID__: string; declare const __APP_FRONT__: string; +declare const __HOME_BASE__: string; diff --git a/src/state/findHomebaseUrl.ts b/src/state/findHomebaseUrl.ts index 4781926..2a39421 100644 --- a/src/state/findHomebaseUrl.ts +++ b/src/state/findHomebaseUrl.ts @@ -10,9 +10,10 @@ export const findHomebaseUrl = (): string | undefined => { // DANGER we need to determine which backend to connect to based on how the UI is accessed // IF/when new environments are added this will need to be updated/maintained - let homeBaseUrl: string | undefined = "http://localhost:8787"; + // let homeBaseUrl: string | undefined = "http://localhost:8787"; // let homeBaseUrl = "https://ai-worker.mjtdev.workers.dev"; // let homeBaseUrl = "https://ai-worker.intelligage.workers.dev"; + let homeBaseUrl: string | undefined = __HOME_BASE__; if (/intelligage/i.test(location.hostname)) { homeBaseUrl = "https://ai-worker.intelligage.workers.dev"; } diff --git a/vite.config.ts b/vite.config.ts index 3c7a1f3..c57b666 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -24,9 +24,18 @@ export default defineConfig({ define: { __BUILD_TIMESTAMP__: JSON.stringify(new Date().toISOString()), __APP_VERSION__: JSON.stringify("1.0.0"), + + // Local dev settings + __HOME_BASE__: JSON.stringify("http://localhost:8787"), __PAP_ID__: JSON.stringify( "access-point-1725394696984-a760a179-851e-48d0-b276-85e7a426239c" ), + + // Production settings + // __HOME_BASE__: JSON.stringify("https://ai-worker.intelligage.workers.dev"), + // __PAP_ID__: JSON.stringify( + // "access-point-1725571260862-23455f95-1253-4dfe-96e3-952ac6af647c" + // ), __APP_FRONT__: JSON.stringify("pizza-demo"), }, });