From 46da0d78fdd1979e04d342c557e8736cc0b96551 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Tue, 3 Feb 2026 01:52:21 -0500 Subject: [PATCH] Add CORS debug logging and endpoint --- backend/app/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/app/main.py b/backend/app/main.py index bd8b6117..47f10349 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -20,6 +20,7 @@ async def lifespan(app: FastAPI): # Startup logger.info("Starting Patherly API server...") logger.info(f"Environment: {'Development' if settings.DEBUG else 'Production'}") + logger.info(f"ALLOW_RAILWAY_ORIGINS: {settings.ALLOW_RAILWAY_ORIGINS}") # Note: In production, use Alembic migrations instead of init_db # await init_db() yield @@ -87,3 +88,13 @@ async def root(): async def health_check(): """Health check endpoint.""" 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" if settings.ALLOW_RAILWAY_ORIGINS else "list", + "allowed_origins": settings.allowed_origins if not settings.ALLOW_RAILWAY_ORIGINS else "*.up.railway.app (regex)" + }