fix(middleware): update public paths in TenantMiddleware and adjust API routes in main.py
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user