From 7c2a38788b50e0635e3f8d95d629df3b15f975f5 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Wed, 17 Dec 2025 16:06:18 +0200 Subject: [PATCH] fix dynamic env --- frontend/index.html | 2 ++ frontend/public/env.js | 3 +++ frontend/public/env.js.template | 3 +++ frontend/src/api.js | 4 ++-- 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 frontend/public/env.js create mode 100644 frontend/public/env.js.template diff --git a/frontend/index.html b/frontend/index.html index 7afc70c..b1ebdaf 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,6 +5,8 @@ Dating App + +
diff --git a/frontend/public/env.js b/frontend/public/env.js new file mode 100644 index 0000000..7bc8e0a --- /dev/null +++ b/frontend/public/env.js @@ -0,0 +1,3 @@ +window.__ENV__ = { + API_BASE: "http://localhost:8000" +}; diff --git a/frontend/public/env.js.template b/frontend/public/env.js.template new file mode 100644 index 0000000..d289065 --- /dev/null +++ b/frontend/public/env.js.template @@ -0,0 +1,3 @@ +window.__ENV__ = { + API_BASE: "${API_BASE:-http://localhost:8000}" +}; diff --git a/frontend/src/api.js b/frontend/src/api.js index 08ac0c1..a821b82 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -1,7 +1,7 @@ import axios from 'axios' -// Get API base URL from environment or default -const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000' +// Get API base URL from runtime environment (window.__ENV__) or build-time env +const API_BASE_URL = window.__ENV__?.API_BASE || import.meta.env.VITE_API_URL || 'http://localhost:8000' // Create axios instance with default config const api = axios.create({