Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

🔧(frontend) refactor API URl to work for remote environments

antoine lebauda480c5022126
diff --git a/src/frontend/.env.development b/src/frontend/.env.development
index 1a71fafa..520d2fb3 100644
--- a/src/frontend/.env.development
+++ b/src/frontend/.env.development
@@ -1,2 +1,2 @@
-VITE_API_BASE_URL=http://localhost:8071/api/v1.0/
+VITE_API_BASE_URL=http://localhost:8071/
VITE_LIVEKIT_SERVER_URL=http://localhost:7880
diff --git a/src/frontend/src/api/apiUrl.ts b/src/frontend/src/api/apiUrl.ts
index dc1d3c2a..f4032197 100644
--- a/src/frontend/src/api/apiUrl.ts
+++ b/src/frontend/src/api/apiUrl.ts
@@ -1,3 +1,12 @@
-export const apiUrl = (path: string) => {
- return `${import.meta.env.VITE_API_BASE_URL.replace(/\/$/, '')}${path}`
+export const apiUrl = (path: string, apiVersion = '1.0') => {
+
+ const origin =
+ import.meta.env.VITE_API_BASE_URL
+ || (typeof window !== 'undefined' ? window.location.origin : '');
+
+ // Remove leading/trailing slashes from origin/path if it exists
+ const sanitizedOrigin = origin.replace(/\/$/, '')
+ const sanitizedPath = path.replace(/^\//, '');
+
+ return `${sanitizedOrigin}/api/v${apiVersion}/${sanitizedPath}`;
}
diff --git a/src/helm/env.d/dev/values.meet.yaml.gotmpl b/src/helm/env.d/dev/values.meet.yaml.gotmpl
index 7d34d238..e4a8417f 100644
--- a/src/helm/env.d/dev/values.meet.yaml.gotmpl
+++ b/src/helm/env.d/dev/values.meet.yaml.gotmpl
@@ -79,7 +79,7 @@ frontend:
envVars:
VITE_PORT: 8080
VITE_HOST: 0.0.0.0
- VITE_API_BASE_URL: https://meet.127.0.0.1.nip.io/api/v1.0/
+ VITE_API_BASE_URL: https://meet.127.0.0.1.nip.io/
VITE_LIVEKIT_SERVER_URL: https://livekit.127.0.0.1.nip.io/
replicas: 1