fix(ui): Loading .env

This commit is contained in:
Richard Palethorpe
2025-03-31 12:28:55 +01:00
parent 29beee6057
commit 8e703c0ac2

View File

@@ -1,32 +1,37 @@
import { defineConfig } from 'vite' import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
// Define backend URL with port from environment variable or default to 8080 export default defineConfig(({ mode }) => {
const backendUrl = `http://${process.env.BACKEND_HOST || 'localhost'}:${process.env.BACKEND_PORT || '3000'}` // Load environment variables
const env = loadEnv(mode, process.cwd(), '')
// https://vitejs.dev/config/ // Define backend URL with port from environment variable or default to 8080
export default defineConfig({ const backendUrl = `http://${env.BACKEND_HOST || 'localhost'}:${env.BACKEND_PORT || '3000'}`
plugins: [react()],
base: '/app', // Set the base path for production builds return {
server: { plugins: [react()],
proxy: { base: '/app', // Set the base path for production builds
// Proxy API requests to your Go backend server: {
'/api': backendUrl, proxy: {
// Proxy SSE endpoints // Proxy API requests to your Go backend
'/sse': backendUrl, '/api': backendUrl,
// Add other endpoints as needed // Proxy SSE endpoints
'/settings': backendUrl, '/sse': backendUrl,
'/agents': backendUrl, // Add other endpoints as needed
'/create': backendUrl, '/settings': backendUrl,
'/delete': backendUrl, '/agents': backendUrl,
'/pause': backendUrl, '/create': backendUrl,
'/start': backendUrl, '/delete': backendUrl,
'/talk': backendUrl, '/pause': backendUrl,
'/notify': backendUrl, '/start': backendUrl,
'/chat': backendUrl, '/talk': backendUrl,
'/status': backendUrl, '/notify': backendUrl,
'/action': backendUrl, '/chat': backendUrl,
'/actions': backendUrl, '/status': backendUrl,
'/action': backendUrl,
'/actions': backendUrl,
}
} }
} }
}); });