2026-05-18 16:32:42 +08:00
|
|
|
import { defineConfig, loadEnv } from 'vite'
|
2026-05-14 15:07:34 +08:00
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
2026-05-18 16:32:42 +08:00
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
const env = loadEnv(mode, process.cwd(), '')
|
2026-05-25 13:58:48 +08:00
|
|
|
// Default local frontend development to the local backend unless explicitly overridden.
|
|
|
|
|
const apiHost = env.API_HOST || '127.0.0.1'
|
2026-05-18 16:32:42 +08:00
|
|
|
const apiPort = env.API_PORT || '8000'
|
|
|
|
|
const proxyTarget = env.VITE_API_PROXY_TARGET || `http://${apiHost}:${apiPort}`
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
plugins: [react()],
|
|
|
|
|
server: {
|
|
|
|
|
host: '0.0.0.0',
|
|
|
|
|
port: Number(env.FRONTEND_PORT || 5173),
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: proxyTarget,
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
},
|
2026-05-14 15:07:34 +08:00
|
|
|
},
|
|
|
|
|
},
|
2026-05-18 16:32:42 +08:00
|
|
|
}
|
2026-05-14 15:07:34 +08:00
|
|
|
})
|