aps-agent/apps/web/vite.config.ts

26 lines
962 B
TypeScript
Raw Permalink Normal View History

2026-07-21 11:05:57 +08:00
// ============================================================
// Vite 构建配置(moduleId: web-vite-config, 可重生 ✅)
// 职责:React 插件注册 + 开发代理(/api → 本地 FastAPI)
// ============================================================
import { defineConfig } from 'vite'; // Vite 配置工厂
import react from '@vitejs/plugin-react'; // React 快速刷新插件
// 导出 Vite 配置
export default defineConfig({
// 注册 React 插件(JSX 转译 + HMR)
plugins: [react()],
server: {
// 开发端口固定 5173,便于 README 文档指引
port: 5173,
proxy: {
// 前端所有 /api 请求代理到本地 FastAPI(避免跨域)
'/api': {
// 后端默认地址(与 .env 的 APS_PORT 一致)
target: process.env.VITE_API_TARGET || 'http://localhost:8000',
2026-07-21 11:05:57 +08:00
// 允许改写 Origin,SSE 需要
changeOrigin: true,
},
},
},
});