From f85a1efa29693eb66909ee61b085c9f77c2b4f81 Mon Sep 17 00:00:00 2001 From: antoine lebaud Date: Tue, 2 Jul 2024 16:22:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(frontend)=20pass=20API=20and=20Liv?= =?UTF-8?q?eKit=20server=20URLs=20through=20environment=20vars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configured the frontend to use environment variables (prefixed with "VITE_") for API and LiveKit server URLs, which will be overridden in the Helm chart values to ensure correct URLs are used in different environments. --- src/frontend/.env.development | 2 ++ src/frontend/src/App.tsx | 4 ++-- src/frontend/src/vite-env.d.ts | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/frontend/.env.development diff --git a/src/frontend/.env.development b/src/frontend/.env.development new file mode 100644 index 00000000..1a71fafa --- /dev/null +++ b/src/frontend/.env.development @@ -0,0 +1,2 @@ +VITE_API_BASE_URL=http://localhost:8071/api/v1.0/ +VITE_LIVEKIT_SERVER_URL=http://localhost:7880 diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 52b7a7a8..1ce3cfff 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -4,8 +4,8 @@ import {LiveKitRoom, VideoConference} from "@livekit/components-react"; import '@livekit/components-styles'; -const API_BASE_URL = 'http://localhost:8071/api/v1.0/' -const LIVEKIT_SERVER_URL = 'http://localhost:7880' +const API_BASE_URL = import.meta.env.VITE_API_BASE_URL +const LIVEKIT_SERVER_URL = import.meta.env.VITE_LIVEKIT_SERVER_URL export interface User { id: string; diff --git a/src/frontend/src/vite-env.d.ts b/src/frontend/src/vite-env.d.ts index 11f02fe2..a776d27c 100644 --- a/src/frontend/src/vite-env.d.ts +++ b/src/frontend/src/vite-env.d.ts @@ -1 +1,9 @@ /// +interface ImportMetaEnv { + readonly VITE_API_BASE_URL: string; + readonly VITE_LIVEKIT_SERVER_URL: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +}