From 2e5cf13b3f4ed41b269a39fde68c4fc1cac29d42 Mon Sep 17 00:00:00 2001 From: lirazyehezkel <61656597+lirazyehezkel@users.noreply.github.com> Date: Mon, 31 Jan 2022 12:05:50 +0200 Subject: [PATCH] Mizu start dev commands (#726) * start dev commands * env files * no message --- ui/.env.dev.basic | 3 +++ ui/.env.dev.enterprise | 3 +++ ui/package.json | 3 ++- ui/src/helpers/api.js | 5 +++-- 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 ui/.env.dev.basic create mode 100644 ui/.env.dev.enterprise diff --git a/ui/.env.dev.basic b/ui/.env.dev.basic new file mode 100644 index 000000000..94b65687c --- /dev/null +++ b/ui/.env.dev.basic @@ -0,0 +1,3 @@ +REACT_APP_OVERRIDE_WS_URL="ws://localhost:8899/ws" +REACT_APP_OVERRIDE_API_URL="http://localhost:8899/" +REACT_APP_OVERRIDE_IS_ENTERPRISE="false" diff --git a/ui/.env.dev.enterprise b/ui/.env.dev.enterprise new file mode 100644 index 000000000..4a7c3e4e6 --- /dev/null +++ b/ui/.env.dev.enterprise @@ -0,0 +1,3 @@ +REACT_APP_OVERRIDE_WS_URL="ws://localhost:8899/ws" +REACT_APP_OVERRIDE_API_URL="http://localhost:8899/" +REACT_APP_OVERRIDE_IS_ENTERPRISE="true" diff --git a/ui/package.json b/ui/package.json index 06baecb42..345270d15 100644 --- a/ui/package.json +++ b/ui/package.json @@ -49,7 +49,8 @@ }, "scripts": { "start": "craco start", - "start-ent": "./node_modules/.bin/env-cmd -f .env.enterprise craco start", + "start-dev": "./node_modules/.bin/env-cmd -f .env.dev.basic craco start", + "start-dev-ent": "./node_modules/.bin/env-cmd -f .env.dev.enterprise craco start", "build": "./node_modules/.bin/env-cmd -f .env.basic craco build", "build-ent": "BUILD_PATH='./build-ent' ./node_modules/.bin/env-cmd -f .env.enterprise craco build", "test": "craco test", diff --git a/ui/src/helpers/api.js b/ui/src/helpers/api.js index 455d72861..65ddc2b46 100644 --- a/ui/src/helpers/api.js +++ b/ui/src/helpers/api.js @@ -1,12 +1,13 @@ import * as axios from "axios"; -export const MizuWebsocketURL = window.location.protocol === 'https:' ? `wss://${window.location.host}/ws` : `ws://${window.location.host}/ws`; +export const MizuWebsocketURL = process.env.REACT_APP_OVERRIDE_WS_URL ? process.env.REACT_APP_OVERRIDE_WS_URL : + window.location.protocol === 'https:' ? `wss://${window.location.host}/ws` : `ws://${window.location.host}/ws`; export const FormValidationErrorType = "formError"; const CancelToken = axios.CancelToken; -const apiURL =`${window.location.origin}/`; +const apiURL = process.env.REACT_APP_OVERRIDE_API_URL ? process.env.REACT_APP_OVERRIDE_API_URL : `${window.location.origin}/`; export default class Api { static instance;