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(), '') const apiTarget = env.VITE_API_PROXY_TARGET || 'http://127.0.0.1:8080' return { base: '/', plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, build: { outDir: 'dist', emptyOutDir: true, sourcemap: false }, server: { port: 5173, proxy: { '/api': { target: apiTarget, changeOrigin: true, configure: (proxy) => { proxy.on('proxyRes', (proxyRes, req) => { if (req.url?.includes('/chat/completions')) { proxyRes.headers['cache-control'] = 'no-cache' proxyRes.headers['x-accel-buffering'] = 'no' } }) } } } } } })