From e944df3d7d431b5bd88c2c235501a355ea1ba6ab Mon Sep 17 00:00:00 2001 From: Parker Date: Tue, 5 Nov 2024 20:36:09 -0600 Subject: Fix auth and organization/standards --- app/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/main.py') diff --git a/app/main.py b/app/main.py index 3ef89f2..90b3104 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,6 @@ from fastapi import FastAPI, Depends, Request from fastapi.middleware.cors import CORSMiddleware -from fastapi.responses import RedirectResponse +from fastapi.responses import RedirectResponse, JSONResponse from fastapi.templating import Jinja2Templates from app.routes.auth_routes import router as auth_router from app.routes.links_routes import router as links_router @@ -151,3 +151,11 @@ async def redirect_to_docs(): @app.exception_handler(HTTP_404_NOT_FOUND) async def custom_404_handler(request: Request, exc: HTTPException): return RedirectResponse(url="/login") + + +@app.exception_handler(HTTPException) +async def http_exception_handler(request, exc): + return JSONResponse( + status_code=exc.status_code, + content={"detail": f"{exc.detail}"}, + ) -- cgit v1.2.3-70-g09d2