Merge branch origin/copilot/sub-pr-3-again into main
This commit is contained in:
@@ -10,15 +10,18 @@ from app.routes.v1.router import router as v1_router
|
|||||||
|
|
||||||
app = FastAPI(title="BlackRoad Public API Gateway", version="0.1.0")
|
app = FastAPI(title="BlackRoad Public API Gateway", version="0.1.0")
|
||||||
|
|
||||||
app.add_middleware(ErrorHandlerMiddleware)
|
# Middleware execution order: Last added = first executed (outermost layer)
|
||||||
app.add_middleware(RequestIdMiddleware)
|
# Request flow: ErrorHandler -> RequestId -> CORS -> App
|
||||||
|
# This ensures ErrorHandler can catch exceptions from all other middleware
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware, # First added = innermost
|
||||||
allow_origins=["*"],
|
allow_origins=["*"],
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=["*"],
|
allow_methods=["*"],
|
||||||
allow_headers=["*"]
|
allow_headers=["*"]
|
||||||
)
|
)
|
||||||
|
app.add_middleware(RequestIdMiddleware) # Second added = middle layer
|
||||||
|
app.add_middleware(ErrorHandlerMiddleware) # Last added = outermost, catches all errors
|
||||||
|
|
||||||
app.include_router(root.router)
|
app.include_router(root.router)
|
||||||
app.include_router(v1_router)
|
app.include_router(v1_router)
|
||||||
|
|||||||
Reference in New Issue
Block a user