From 245b6a42021b6ead44af50d0cee4851668997eb4 Mon Sep 17 00:00:00 2001 From: MytelligentPRV Date: Sat, 20 Jun 2026 10:54:58 -0700 Subject: [PATCH] fix(health): support HEAD on /health (was 405) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /health only allowed GET, so HEAD probes got 405. HEAD is the default method for several uptime monitors, so accept it: @app.api_route methods=[GET, HEAD], returning a bare 200 with empty body for HEAD (skips the catalog DB work — a HEAD probe only wants a liveness signal). GET response unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/api/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/api/main.py b/apps/api/main.py index eb1275f..45231c7 100644 --- a/apps/api/main.py +++ b/apps/api/main.py @@ -1721,9 +1721,14 @@ async def security_policy_html(): return HTMLResponse(_SECURITY_POLICY_HTML) -@app.get("/health") +@app.api_route("/health", methods=["GET", "HEAD"]) @limiter.limit("60/minute") async def health(request: Request): + # Health endpoints are commonly probed with HEAD (it's the default method for + # several uptime monitors). HEAD wants a cheap liveness signal, not the full + # catalog payload — return a bare 200 with an empty body and skip the DB work. + if request.method == "HEAD": + return Response(status_code=200) from core.db import get_pool_stats pool = getattr(request.app.state, "pool", None) # Section 6 (v0.7.8): rename catalog fields to disambiguate. The old shape