From 09a0a17f9a4749a0ad36d81f5fcc7c5b8e2a11c7 Mon Sep 17 00:00:00 2001 From: acazares Date: Sat, 1 Nov 2025 12:13:45 -0500 Subject: [PATCH] fix(middleware): update public paths in TenantMiddleware and adjust API routes in main.py --- backend/core/middleware.py | 14 +++++++------- backend/main.py | 11 ++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/backend/core/middleware.py b/backend/core/middleware.py index 4ed7155f..459c1fc7 100644 --- a/backend/core/middleware.py +++ b/backend/core/middleware.py @@ -26,15 +26,15 @@ class TenantMiddleware(BaseHTTPMiddleware): async def dispatch(self, request: Request, call_next: Callable): # Rutas públicas que no requieren tenant public_paths = [ - "/docs", - "/redoc", - "/openapi.json", + "/api/docs", + "/api/redoc", + "/api/openapi.json", + "/api/v1/auth", "/api/v1/auth", - "/v1/auth", "/api/v1/status", - "/v1/status", - "/health", - "/" + "/api/v1/status", + "/api/health", + "/api/" ] # Verificar si la ruta es pública (comparación exacta o prefijo) diff --git a/backend/main.py b/backend/main.py index 58f2163b..3932471a 100644 --- a/backend/main.py +++ b/backend/main.py @@ -29,8 +29,9 @@ app = FastAPI( title="Anexo76 API", version=settings.APP_VERSION, description="Aplicación SaaS para gestión de comercio exterior conforme a Anexos 24, 31 y 22 del SAT", - docs_url="/docs" if settings.DEBUG else None, - redoc_url="/redoc" if settings.DEBUG else None + docs_url="/api/docs" if settings.DEBUG else None, + redoc_url="/api/redoc" if settings.DEBUG else None, + openapi_url="/api/openapi.json" if settings.DEBUG else None, ) # Configurar CORS @@ -51,18 +52,18 @@ app.add_middleware(TenantMiddleware) app.include_router(api_v1_router, prefix="/api/v1") -@app.get("/") +@app.get("/api/") async def root(): """Root endpoint""" return { "name": "Anexo76 API", "version": settings.APP_VERSION, "status": "running", - "docs": "/docs" if settings.DEBUG else "disabled in production" + "docs": "/api/docs" if settings.DEBUG else "disabled in production" } -@app.get("/health") +@app.get("/api/health") async def health_check(): """Health check endpoint""" return {