fix-healthcheck-url
main
管理后台右上角永远显示「系统异常」,即使一切正常。
/health
/health/ready
lib/http.ts
build_url
/api/v1
/api/v1/health
fetchHealth
{status: "unknown"}
/health/*
http.test.ts
ApiError
public status
node --experimental-strip-types src/lib/http.test.ts → 7 passed 0 failed(修复前新用例红) tsc --noEmit 0 错误
node --experimental-strip-types src/lib/http.test.ts
build_url 对所有路径强制加 /api/v1,但后端 /health 与 /health/ready 挂在根路径(app.py,与 compose healthcheck 一致)→ 前端请求 /api/v1/health 404 → fetchHealth 吞错返回 status=unknown → 右上角/监控页永远「系统异常」。 - build_url 对 /health 与 /health/* 豁免前缀 - http.test.ts 补 URL 豁免用例(该测试此前因 ApiError 参数属性不被 strip-types 支持而完全无法运行,顺手改为显式赋值使基建可用)
No dependencies set.
The note is not visible to the blocked user.
问题
管理后台右上角永远显示「系统异常」,即使一切正常。
根因
/health、/health/ready挂在根路径(app.py,compose healthcheck 也走这里)lib/http.ts的build_url把所有路径统一加/api/v1前缀 → 实际请求/api/v1/health→ 404fetchHealth吞错返回{status: "unknown"}→ AdminLayout/Monitoring 判定非 healthy → 永远异常修复
build_url对/health与/health/*豁免前缀(其余路径行为不变)http.test.ts补 2 个 URL 用例。顺带修复测试基建:该文件此前因ApiError构造函数参数属性(public status)不被 node strip-types 支持而完全无法运行,改为显式字段赋值(语义等价)后 7 个用例全部可跑验证
node --experimental-strip-types src/lib/http.test.ts→ 7 passed 0 failed(修复前新用例红)tsc --noEmit 0 错误