File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111from typing import AsyncGenerator , Awaitable , Callable
1212
1313import httpx
14- from fastapi import FastAPI , Request
14+ from fastapi import FastAPI , HTTPException , Request
1515from fastapi .middleware .cors import CORSMiddleware
1616from starlette .responses import JSONResponse , Response
1717
@@ -69,7 +69,7 @@ async def api_authentication_middleware(
6969 # Store client_id in request state for later use
7070 request .state .client_id = client_id
7171 return await call_next (request )
72- except Exception as e :
72+ except HTTPException as e :
7373 return JSONResponse (
7474 status_code = 401 ,
7575 content = {
@@ -78,6 +78,15 @@ async def api_authentication_middleware(
7878 "status" : 401 ,
7979 },
8080 )
81+ except Exception as e :
82+ return JSONResponse (
83+ status_code = 500 ,
84+ content = {
85+ "error" : "Internal Server Error" ,
86+ "message" : str (e ),
87+ "status" : 500 ,
88+ },
89+ )
8190
8291
8392# Include routers from different modules
You can’t perform that action at this time.
0 commit comments