import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import { fileURLToPath, URL } from 'node:url' export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), '') // In Docker the backend is reachable at http://backend:8000 via the pmdi_net network. // Override with VITE_API_TARGET env var for other environments. const apiTarget = env.VITE_API_TARGET || 'http://localhost:8000' return { plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, server: { host: '0.0.0.0', port: 3000, proxy: { // Transparently forward all /api requests to the FastAPI backend '/api': { target: apiTarget, changeOrigin: true, secure: false, }, }, }, } })