From 8e703c0ac2eef369712efdaf543de0ff41ee871f Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Mon, 31 Mar 2025 12:28:55 +0100 Subject: [PATCH] fix(ui): Loading .env --- webui/react-ui/vite.config.js | 59 +++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/webui/react-ui/vite.config.js b/webui/react-ui/vite.config.js index 8b50d2e..1edbc85 100644 --- a/webui/react-ui/vite.config.js +++ b/webui/react-ui/vite.config.js @@ -1,32 +1,37 @@ -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' -// Define backend URL with port from environment variable or default to 8080 -const backendUrl = `http://${process.env.BACKEND_HOST || 'localhost'}:${process.env.BACKEND_PORT || '3000'}` +export default defineConfig(({ mode }) => { + // Load environment variables + const env = loadEnv(mode, process.cwd(), '') -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [react()], - base: '/app', // Set the base path for production builds - server: { - proxy: { - // Proxy API requests to your Go backend - '/api': backendUrl, - // Proxy SSE endpoints - '/sse': backendUrl, - // Add other endpoints as needed - '/settings': backendUrl, - '/agents': backendUrl, - '/create': backendUrl, - '/delete': backendUrl, - '/pause': backendUrl, - '/start': backendUrl, - '/talk': backendUrl, - '/notify': backendUrl, - '/chat': backendUrl, - '/status': backendUrl, - '/action': backendUrl, - '/actions': backendUrl, + // Define backend URL with port from environment variable or default to 8080 + const backendUrl = `http://${env.BACKEND_HOST || 'localhost'}:${env.BACKEND_PORT || '3000'}` + + return { + plugins: [react()], + base: '/app', // Set the base path for production builds + server: { + proxy: { + // Proxy API requests to your Go backend + '/api': backendUrl, + // Proxy SSE endpoints + '/sse': backendUrl, + // Add other endpoints as needed + '/settings': backendUrl, + '/agents': backendUrl, + '/create': backendUrl, + '/delete': backendUrl, + '/pause': backendUrl, + '/start': backendUrl, + '/talk': backendUrl, + '/notify': backendUrl, + '/chat': backendUrl, + '/status': backendUrl, + '/action': backendUrl, + '/actions': backendUrl, + } } } -}); \ No newline at end of file +}); +