From f7307842f14203bca2a36ddaaae014c151af0080 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 3 Sep 2026 15:24:20 +0800 Subject: [PATCH] fix(healthcheck): accept 404 for /docs in production health check Production sets docs_url=None in main.py (FastAPI), so /docs returns 404. The health check now treats 404 as healthy (API is responding, just docs are disabled). 200 still passes for staging/other envs. --- scripts/ci_production_healthcheck.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci_production_healthcheck.sh b/scripts/ci_production_healthcheck.sh index a73fd5ba0..72abd9f26 100644 --- a/scripts/ci_production_healthcheck.sh +++ b/scripts/ci_production_healthcheck.sh @@ -160,11 +160,11 @@ health_check() { web_ok=true fi - # 检查 API docs + # 检查 API docs(生产环境禁用 /docs,404 表示 API 在正常响应,视为健康) if [ "$api_docs_ok" = false ]; then HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "${PROD_API_URL}/docs" 2>/dev/null || echo "000") - if [ "$HTTP_CODE" = "200" ]; then - log_info "✅ API Docs 检查通过" + if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "404" ]; then + log_info "✅ API Docs 检查通过(HTTP $HTTP_CODE)" api_docs_ok=true fi fi -- 2.54.0