Fix: Resolve route conflict - move root JSON endpoint to /api

The root / endpoint in main.py was conflicting with the HTML
  endpoint in auth.router, causing the homepage to return JSON
  instead of rendering the HTML dashboard. Moved API info to /api
  to allow auth.router to properly handle / and /login pages.
This commit is contained in:
richardtekula
2025-11-11 16:57:38 +01:00
parent f9c80c375a
commit a3b609eab7

View File

@@ -313,14 +313,14 @@ async def health_check() -> Dict[str, Any]:
"database_status": db_status "database_status": db_status
} }
# Include routers # Include routers - auth.router handles / and /login HTML pages
app.include_router(auth.router, prefix="/auth", tags=["Auth"]) app.include_router(auth.router, prefix="/auth", tags=["Auth"])
app.include_router(auth.router, prefix="", tags=["Auth"]) app.include_router(auth.router, prefix="", tags=["Auth"])
# Root endpoint # API info endpoint (moved from / to /api to avoid conflict with auth.router)
@app.get("/", tags=["Root"]) @app.get("/api", tags=["API Info"])
async def root() -> Dict[str, Any]: async def api_info() -> Dict[str, Any]:
"""Root endpoint with API information""" """API information endpoint"""
return { return {
"message": AppConfig.APP_NAME, "message": AppConfig.APP_NAME,
"version": AppConfig.VERSION, "version": AppConfig.VERSION,