From 97303e6f26e8336a1a6f04b0789dc9c94bd89470 Mon Sep 17 00:00:00 2001 From: sumn2u Date: Tue, 11 Jun 2024 13:43:22 -0500 Subject: [PATCH] use environment or configuration endpoint --- client/config.js | 10 +++++++++- client/src/SetupPage/SetupPage.test.js | 5 +++++ .../workspace/DownloadButton/DownloadButton.test.js | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/config.js b/client/config.js index 93c399a..a832314 100644 --- a/client/config.js +++ b/client/config.js @@ -1,7 +1,15 @@ +let VITE_SERVER_URL; + +if (typeof import.meta !== 'undefined' && import.meta.env) { + VITE_SERVER_URL = import.meta.env.VITE_SERVER_URL; +} else { + VITE_SERVER_URL = process.env.VITE_SERVER_URL || "http://localhost:5000"; +} + const config = { DEMO_SITE_URL:"https://annotate-docs.dwaste.live/", - VITE_SERVER_URL: "http://localhost:5000", + VITE_SERVER_URL }; export default config; diff --git a/client/src/SetupPage/SetupPage.test.js b/client/src/SetupPage/SetupPage.test.js index aaa1382..08bda4f 100644 --- a/client/src/SetupPage/SetupPage.test.js +++ b/client/src/SetupPage/SetupPage.test.js @@ -11,6 +11,11 @@ jest.mock('react-i18next', () => ({ }), })); +jest.mock('../../config.js', () => ({ + DEMO_SITE_URL: "https://annotate-docs.dwaste.live/", + VITE_SERVER_URL: "http://localhost:5000", +})); + // Mock useSettings hook jest.mock('../SettingsProvider', () => ({ useSettings: jest.fn(), diff --git a/client/src/workspace/DownloadButton/DownloadButton.test.js b/client/src/workspace/DownloadButton/DownloadButton.test.js index b4691aa..9f67428 100644 --- a/client/src/workspace/DownloadButton/DownloadButton.test.js +++ b/client/src/workspace/DownloadButton/DownloadButton.test.js @@ -10,6 +10,12 @@ jest.mock('../../SnackbarContext/index.jsx', () => ({ }), })); +jest.mock('../../../config.js', () => ({ + DEMO_SITE_URL: "https://annotate-docs.dwaste.live/", + VITE_SERVER_URL: "http://localhost:5000", + })); + + // Mock the useTranslation hook with actual translations jest.mock('react-i18next', () => ({ useTranslation: () => ({