From 4e1122ca8a0a29a25b5ebbb8bf709abd7bd3d7c5 Mon Sep 17 00:00:00 2001 From: Ludovic DEHON Date: Tue, 30 Apr 2024 16:17:44 +0200 Subject: [PATCH] feat(ui): handle env file for dev --- client/vite.config.mjs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/client/vite.config.mjs b/client/vite.config.mjs index 00de76e10..b86c34be8 100644 --- a/client/vite.config.mjs +++ b/client/vite.config.mjs @@ -1,7 +1,9 @@ -import { defineConfig } from 'vite'; +import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; -export default defineConfig(() => { +export default defineConfig(({ command, mode }) => { + const env = loadEnv(mode, process.cwd(), '') + return { base: '/ui', build: { @@ -34,16 +36,16 @@ export default defineConfig(() => { open: true, proxy: { '/api': { - target: 'http://localhost:8080' + target: env.APP_BASE_URL || 'http://localhost:8080' }, '/login': { - target: 'http://localhost:8080' + target: env.APP_BASE_URL || 'http://localhost:8080' }, '/logout': { - target: 'http://localhost:8080' + target: env.APP_BASE_URL || 'http://localhost:8080' }, '/oauth': { - target: 'http://localhost:8080' + target: env.APP_BASE_URL || 'http://localhost:8080' } } },