diff --git a/client/babel.config.json b/client/babel.config.json new file mode 100644 index 0000000..38f5094 --- /dev/null +++ b/client/babel.config.json @@ -0,0 +1,5 @@ +{ + "presets": [ + "@babel/preset-env" + ] +} \ No newline at end of file diff --git a/client/config.js b/client/config.js index baaebd2..a832314 100644 --- a/client/config.js +++ b/client/config.js @@ -1,7 +1,16 @@ +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 = { - demoSiteUrl:"https://annotate-docs.dwaste.live/" + DEMO_SITE_URL:"https://annotate-docs.dwaste.live/", + VITE_SERVER_URL }; - export default config; +export default config; \ No newline at end of file diff --git a/client/src/DemoSite/index.jsx b/client/src/DemoSite/index.jsx index fec7db8..29767ec 100644 --- a/client/src/DemoSite/index.jsx +++ b/client/src/DemoSite/index.jsx @@ -161,7 +161,7 @@ export default () => { const updatedIndex = (selectedImageIndex - 1 + imageNames.length) % imageNames.length changeSelectedImageIndex(isNaN(updatedIndex ) ? 0 : updatedIndex) }} - openDocs={() => window.open(config.demoSiteUrl, '_blank')} + openDocs={() => window.open(config.DEMO_SITE_URL, '_blank')} hideSettings={true} disabledNextAndPrev={settings.images.length <= 1} selectedImageIndex={selectedImageIndex} 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/SetupPage/index.jsx b/client/src/SetupPage/index.jsx index 87c425e..54f8dd3 100644 --- a/client/src/SetupPage/index.jsx +++ b/client/src/SetupPage/index.jsx @@ -111,7 +111,7 @@ export const SetupPage = ({setConfiguration, settings, setShowLabel}) => {