From a65066fe085cb3b9c5040af0e827df3ce3118ab7 Mon Sep 17 00:00:00 2001 From: CM Consultor Date: Sun, 9 Aug 2026 05:14:35 +0000 Subject: [PATCH] fix: health check aceita HEAD (Docker Swarm) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O health check do Swarm usa HEAD, não GET. HEAD retornava 405 e o container era morto. --- api.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api.py b/api.py index e657216..cb475a5 100644 --- a/api.py +++ b/api.py @@ -103,10 +103,17 @@ def root(): } -@app.get("/health") +@app.api_route("/health", methods=["GET", "HEAD"]) def health(): - """Health check — sem autenticação.""" - return {"status": "ok", "version": API_VERSION, "auth": is_auth_enabled()} + """Health check — sem autenticação. Suporta GET e HEAD (Docker Swarm).""" + from fastapi.responses import JSONResponse + return JSONResponse( + content={"status": "ok"}, + headers={ + "X-Api-Status": "ok", + "X-Api-Version": API_VERSION, + }, + ) # ── Endpoints Protegidos ────────────────────────────────────────────