diff --git a/backend/app/main.py b/backend/app/main.py index 9744393..4f3a536 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -121,8 +121,7 @@ origins = [ app.add_middleware( CORSMiddleware, - allow_origins=origins, - allow_origin_regex="https://.*sibu.*\.vercel\.app", # Permitir subdominios de vercel con 'sibu' + allow_origins=["*"], # Abrir temporalmente para diagnóstico allow_credentials=True, allow_methods=["*"], allow_headers=["*"], @@ -134,8 +133,9 @@ logger = logging.getLogger(__name__) @app.exception_handler(Exception) async def global_exception_handler(request, exc): - logger.error(f"Global error: {exc}", exc_info=True) - return {"detail": "Internal Server Error", "message": str(exc)} + # Loguear de forma segura sin caracteres especiales que rompan el terminal + logger.error(f"Global error on {request.url.path}: {str(exc)}") + return {"detail": "Internal Server Error", "message": "Verify database connection or payload"} # Ensure upload directories exist for sub in ["profiles", "vehicles", "businesses"]: @@ -167,6 +167,17 @@ async def root(): @app.get("/health") -async def health(): - """Health check endpoint.""" - return {"status": "healthy", "environment": settings.environment} +async def health(session: Session = Depends(get_session)): + """Health check endpoint connecting to DB.""" + db_status = "connected" + try: + from sqlalchemy import text + session.execute(text("SELECT 1")) + except Exception as e: + db_status = f"disconnected: {str(e)}" + + return { + "status": "healthy" if db_status == "connected" else "degraded", + "environment": settings.environment, + "database": db_status + }