Files
get_wechat/chatlab-web/frontend/vite.config.js

35 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 },
},
},
})