Skip to content

fix: support HEAD method on health check routes, allow localhost in s…#74

Merged
stenwire merged 1 commit into
mainfrom
root-dir-dockerfile
Jul 4, 2026
Merged

fix: support HEAD method on health check routes, allow localhost in s…#74
stenwire merged 1 commit into
mainfrom
root-dir-dockerfile

Conversation

@stenwire

@stenwire stenwire commented Jul 4, 2026

Copy link
Copy Markdown
Owner

…taging 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.

Description

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • Infrastructure / CI / tooling

Checklist

  • My code follows the existing code style of this project
  • I have tested my changes locally
  • Lint passes (make lint-be / make lint-fe)
  • Tests pass (make test-be / make test-fe)
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

Screenshots / Demo

Related Issues

…taging 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 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

🤖 Hi @stenwire, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@stenwire
stenwire merged commit 986e26a into main Jul 4, 2026
4 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds 'localhost' and '127.0.0.1' to the allowed hosts in the staging configuration and updates the root and health check endpoints to support both GET and HEAD methods. The reviewer recommends extending the allowed hosts update to the production configuration as well to prevent potential health check failures in production.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +99 to +100
"localhost",
"127.0.0.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

While adding "localhost" and "127.0.0.1" to StagingConfig.ALLOWED_HOSTS successfully resolves the health check failures in staging, the production environment (ProductionConfig) will likely suffer from the exact same issue if it is also hosted on Render (or any platform using local loopback health probes).

To prevent production deployment failures or health check rejections by TrustedHostMiddleware, please ensure "localhost" and "127.0.0.1" are also added to ProductionConfig.ALLOWED_HOSTS:

class ProductionConfig(BaseConfig):
    ...
    ALLOWED_HOSTS: List[str] = [
        "taimako.dubem.xyz",
        "api.taimako.dubem.xyz",
        "*.taimako.dubem.xyz",
        "localhost",
        "127.0.0.1",
    ]

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## 📋 Review Summary

This pull request introduces a well-defined fix to support HEAD requests for health checks and correctly configures ALLOWED_HOSTS for the staging environment. The changes are clear, concise, and directly address the issue of compatibility with Render's health probes.

🔍 General Feedback

  • The changes are logical and correctly implemented.
  • The explanation in the pull request description is clear and helpful for understanding the context.
  • The code quality is good, and the changes align with the existing project structure.

Comment on lines +99 to 101
"localhost",
"127.0.0.1",
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 For better maintainability, consider adding a comment explaining why `localhost` and `127.0.0.1` are included in the allowed hosts for the staging environment. This provides helpful context for future developers.
Suggested change
"localhost",
"127.0.0.1",
]
"taimako.onrender.com",
"taimakoai.onrender.com",
# Allow health checks from Render's internal network
"localhost",
"127.0.0.1",
]

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## 📋 Security Analysis Summary

This pull request aims to improve the health check functionality by adding support for the HEAD method and allowing localhost for staging environment health checks. While the proposed changes are functionally correct, a security audit of the codebase revealed a critical vulnerability related to a hardcoded JWT secret.

🔍 General Feedback

  • The changes in this pull request are well-contained and address the issue of health checks effectively.
  • The codebase is generally well-structured, but the audit surfaced a critical security issue that should be addressed immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant