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

26 lines
931 B
TypeScript
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.

// ============================================================
// 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: 'http://localhost:8000',
// 允许改写 Origin,SSE 需要
changeOrigin: true,
},
},
},
});