import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' import path from 'path' export default defineConfig(({ mode }) => { const env = { ...loadEnv(mode, __dirname, ''), ...process.env } // Local AgentBuilder instances reject cross-origin requests, so the dev // server proxies /api (HTTP and WebSocket) to keep the chat same-origin. const target = env.VITE_AGENTBUILDER_URL || 'http://localhost:5173' return { root: __dirname, plugins: [ react(), tailwindcss(), ], resolve: { alias: { '@': path.resolve(__dirname, '../src'), }, }, server: { host: '0.0.0.0', port: 5174, strictPort: true, allowedHosts: true, proxy: { '/api': { target, ws: true, // Keep the browser's Host so the runtime sees a same-origin request. changeOrigin: false, }, }, }, build: { outDir: '../dist/vite', }, } })