import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); const backendPort = env.PORT ?? '3001'; const backendTarget = env.VITE_API_PROXY_TARGET ?? `http://localhost:${backendPort}`; return { plugins: [react()], server: { proxy: { '/api': { target: backendTarget, changeOrigin: true, secure: false, }, }, }, }; });