diff --git a/web/ui-react/.env b/web/ui-react/.env new file mode 100644 index 0000000..ef81b9c --- /dev/null +++ b/web/ui-react/.env @@ -0,0 +1 @@ +REACT_APP_API_ROOT=http://localhost:1323 \ No newline at end of file diff --git a/web/ui-react/.env.development b/web/ui-react/.env.development deleted file mode 100644 index e69de29..0000000 diff --git a/web/ui-react/.env.production b/web/ui-react/.env.production new file mode 100644 index 0000000..592954e --- /dev/null +++ b/web/ui-react/.env.production @@ -0,0 +1 @@ +REACT_APP_API_ROOT=http://192.168.2.154:1323 \ No newline at end of file diff --git a/web/ui-react/package.json b/web/ui-react/package.json index e099497..d4efe4a 100644 --- a/web/ui-react/package.json +++ b/web/ui-react/package.json @@ -23,8 +23,8 @@ }, "scripts": { "start": "react-scripts start", - "build": "react-scripts build && mv build '../ui-serve/'", - "build:dev": "dotenv -e .env.development react-scripts build", + "build": "set NODE_ENV=production && react-scripts build && mv build '../ui-serve/'", + "build:dev": "set NODE_ENV=development && dotenv -e .env.production react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, diff --git a/web/ui-react/src/service.ts b/web/ui-react/src/service.ts index db1aeae..40d6d23 100644 --- a/web/ui-react/src/service.ts +++ b/web/ui-react/src/service.ts @@ -1,10 +1,10 @@ export const fetchConfiguration = async () => { - const res = await fetch('http://localhost:1323/api/config') + const res = await fetch(`${process.env.REACT_APP_API_ROOT}/api/config`) return res.json() } export const saveConfiguration = async (conf: any) => { - const res = await fetch('http://localhost:1323/api/config', { + const res = await fetch(`${process.env.REACT_APP_API_ROOT}/api/config`, { method: "POST", headers: { 'Content-Type': 'application/json' @@ -15,6 +15,6 @@ export const saveConfiguration = async (conf: any) => { } export const fetchLogs = async (nItems: number, grepFor?: string) => { - const res = await fetch(`http://localhost:1323/api/log?nItems=${nItems}&grepFor=${grepFor}`) + const res = await fetch(`${process.env.REACT_APP_API_ROOT}/api/log?nItems=${nItems}&grepFor=${grepFor}`) return await res.text(); } \ No newline at end of file