From 7b8716a2fef9240b7e302b17ad467c1f843d18bb Mon Sep 17 00:00:00 2001 From: Stephen Nwankwo Date: Sat, 4 Jul 2026 21:55:58 +0100 Subject: [PATCH] fix: support HEAD method on health check routes, allow localhost in staging hosts Render's internal health probe uses HEAD / from 127.0.0.1. FastAPI's automatic HEAD handling wasn't firing (likely due to middleware ordering), so we explicitly register GET+HEAD on both / and /health. Also add localhost and 127.0.0.1 to StagingConfig ALLOWED_HOSTS so TrustedHostMiddleware doesn't reject Render's internal health checks. Co-Authored-By: Claude Sonnet 4.6 --- backend/app/core/config.py | 2 ++ backend/app/main.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 08a4df1..baea55f 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -96,6 +96,8 @@ class StagingConfig(BaseConfig): ALLOWED_HOSTS: List[str] = [ "taimako.onrender.com", "taimakoai.onrender.com", + "localhost", + "127.0.0.1", ] class ProductionConfig(BaseConfig): diff --git a/backend/app/main.py b/backend/app/main.py index 79904aa..80c8c0c 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -91,10 +91,10 @@ app.include_router(orders_router) -@app.get("/") +@app.api_route("/", methods=["GET", "HEAD"]) async def root(): return success_response(message="Agentic RAG API is running") -@app.get("/health") +@app.api_route("/health", methods=["GET", "HEAD"]) async def health_check(): return {"status": "healthy"}