diff options
author | Parker <contact@pkrm.dev> | 2024-11-05 20:36:09 -0600 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-11-05 20:36:09 -0600 |
commit | e944df3d7d431b5bd88c2c235501a355ea1ba6ab (patch) | |
tree | 283a28cb77f2439d20ba00869de15cf65c2c450a /app/main.py | |
parent | 6f7e810916fd2de39d451886bbe18167e1784315 (diff) |
Fix auth and organization/standards
Diffstat (limited to 'app/main.py')
-rw-r--r-- | app/main.py | 10 |
1 files changed, 9 insertions, 1 deletions
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}"}, + ) |