import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') const backendUrl = env.VITE_BACKEND_URL || 'http://localhost:7860' const backendWsUrl = backendUrl.replace(/^http/, 'ws') return { plugins: [react()], server: { proxy: { '/api': { target: backendUrl, changeOrigin: true, secure: false, }, '/ws': { target: backendWsUrl, ws: true, changeOrigin: true, secure: false, } } } } })