import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' const FASTAPI_PORT = 8000 const CHATLOG_PORT = 5030 export default defineConfig({ plugins: [react()], server: { port: 5173, strictPort: true, host: '127.0.0.1', // 强制绑定到 IPv4,避免 localhost 解析到 IPv6 导致连接失败 proxy: { // chatlog_fastAPI Python 后端:所有业务接口 '/api/search': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/groups': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/topics': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/knowledge': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/tasks': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/ai': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/sse': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/settings': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, '/api/files': { target: `http://127.0.0.1:${FASTAPI_PORT}`, changeOrigin: true }, // chatlog Go 后端:基础通信接口 '/api/v1': { target: `http://127.0.0.1:${CHATLOG_PORT}`, changeOrigin: true }, // chatlog Go 后端:媒体文件直接代理 '/image': { target: `http://127.0.0.1:${CHATLOG_PORT}`, changeOrigin: true }, '/voice': { target: `http://127.0.0.1:${CHATLOG_PORT}`, changeOrigin: true }, '/video': { target: `http://127.0.0.1:${CHATLOG_PORT}`, changeOrigin: true }, '/file': { target: `http://127.0.0.1:${CHATLOG_PORT}`, changeOrigin: true }, '/data': { target: `http://127.0.0.1:${CHATLOG_PORT}`, changeOrigin: true }, }, }, })