diff --git a/.env.development b/.env.development index 3dd79763..0b36ced6 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,3 @@ -API_URL=http://localhost:9999 -CONTEXT='' -ADMIN_REGISTRATION_ONLY=false \ No newline at end of file +VITE_API_URL=http://localhost:9999 +VITE_CONTEXT='' +VITE_ADMIN_REGISTRATION_ONLY=false \ No newline at end of file diff --git a/.env.production b/.env.production index 632eb9a7..0981ce0f 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,3 @@ -API_URL=https://kbss.felk.cvut.cz/fta-fmea-server -CONTEXT='/fta-fmea' -ADMIN_REGISTRATION_ONLY=false +VITE_API_URL=https://kbss.felk.cvut.cz/fta-fmea-server +VITE_CONTEXT='/fta-fmea' +VITE_ADMIN_REGISTRATION_ONLY=false diff --git a/src/components/login/Login.tsx b/src/components/login/Login.tsx index 5743e9f9..e2f12f1c 100644 --- a/src/components/login/Login.tsx +++ b/src/components/login/Login.tsx @@ -103,7 +103,7 @@ const Login = () => { > Sign In - {process.env.ADMIN_REGISTRATION_ONLY !== "true" && ( + {import.meta.env.VITE_ADMIN_REGISTRATION_ONLY !== "true" && ( diff --git a/src/components/routes/AppRoutes.tsx b/src/components/routes/AppRoutes.tsx index e58f01a1..ece86b86 100644 --- a/src/components/routes/AppRoutes.tsx +++ b/src/components/routes/AppRoutes.tsx @@ -23,7 +23,7 @@ const AppRoutes = () => { {/*TODO: revisit routing, this is hotfix to support react-router v6*/} - {process.env.ADMIN_REGISTRATION_ONLY === "true" + {import.meta.env.VITE_ADMIN_REGISTRATION_ONLY === "true" ? }/> : }/> } diff --git a/src/services/utils/axiosUtils.tsx b/src/services/utils/axiosUtils.tsx index 431716de..3867f620 100644 --- a/src/services/utils/axiosUtils.tsx +++ b/src/services/utils/axiosUtils.tsx @@ -3,8 +3,7 @@ import {appHistory} from "@components/routes/AppRoutes"; import {ROUTES} from "@utils/constants"; const axiosClient = axios.create({ - // @ts-ignore - baseURL: window.__config__.API_URL + baseURL: import.meta.env.VITE_API_URL }); axiosClient.interceptors.response.use( diff --git a/tsconfig.json b/tsconfig.json index 1360c741..b2956fd7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "none", + "module": "ESNext", "jsx": "react", "target": "es6", "moduleResolution": "node", @@ -19,7 +19,8 @@ "es2017", "dom", "dom.iterable" - ] + ], + "types": ["vite/client"] }, "include": [ "src/*.ts", diff --git a/vite-env.d.ts b/vite-env.d.ts new file mode 100644 index 00000000..26a557c9 --- /dev/null +++ b/vite-env.d.ts @@ -0,0 +1,9 @@ +/// +interface ImportMetaEnv { + VITE_API_URL: string; + VITE_ADMIN_REGISTRATION_ONLY: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} \ No newline at end of file