fix: only register debug endpoint when DEBUG=True
The /debug/cors endpoint is now conditionally registered, preventing information leakage about CORS configuration in production. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,12 +89,13 @@ async def health_check():
|
||||
return {"status": "healthy"}
|
||||
|
||||
|
||||
@app.get("/debug/cors")
|
||||
async def debug_cors():
|
||||
"""Debug endpoint to check CORS configuration."""
|
||||
return {
|
||||
"allow_railway_origins": settings.ALLOW_RAILWAY_ORIGINS,
|
||||
"cors_mode": "regex + list" if settings.ALLOW_RAILWAY_ORIGINS else "list",
|
||||
"allowed_origins": settings.allowed_origins,
|
||||
"railway_regex": r"https://.*\.up\.railway\.app" if settings.ALLOW_RAILWAY_ORIGINS else None
|
||||
}
|
||||
if settings.DEBUG:
|
||||
@app.get("/debug/cors")
|
||||
async def debug_cors():
|
||||
"""Debug endpoint to check CORS configuration."""
|
||||
return {
|
||||
"allow_railway_origins": settings.ALLOW_RAILWAY_ORIGINS,
|
||||
"cors_mode": "regex + list" if settings.ALLOW_RAILWAY_ORIGINS else "list",
|
||||
"allowed_origins": settings.allowed_origins,
|
||||
"railway_regex": r"https://.*\.up\.railway\.app" if settings.ALLOW_RAILWAY_ORIGINS else None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user