mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-15 19:51:59 +00:00
76837d4ef0
踩到的坑:8000 被另一个项目长期占着(绑 *:8000),uvicorn 起不来直接退出, 而健康检查去探 8000 又被那个项目答应了,脚本以为后端就绪继续起前端—— 于是前端代理连着别人的服务,界面上全是陈年旧数据,还很难看出哪里不对。 三处收紧: - 端口被占就自动往后挪(显式指定 AGENTLAB_PORT 时则明确报错并列出占用方) - 健康检查要看到 service 是 agentlab 才算数,顺便看住后端进程别悄悄死了 - vite proxy 的目标端口跟着 AGENTLAB_PORT 走,不再硬编码 8000
20 lines
695 B
TypeScript
20 lines
695 B
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
|
|
// 后端端口跟着 dev.sh 走:8000 被别的项目占了它会自动挪,挪到哪就从
|
|
// 环境变量告诉这边,否则前端会把请求代理到别人的服务上去。
|
|
const API_PORT = process.env.AGENTLAB_PORT || '8000'
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss()],
|
|
server: {
|
|
// 5173 太容易和别的项目撞车,挪开一点
|
|
port: 5273,
|
|
proxy: {
|
|
// 前端开发服务器代理到后端,省掉跨域配置
|
|
'/api': { target: `http://127.0.0.1:${API_PORT}`, changeOrigin: true, ws: true },
|
|
},
|
|
},
|
|
})
|