From 73178cf519525fe92a06a695a3dca0978ba7ce28 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 27 May 2024 11:08:01 -0700 Subject: [PATCH] refac --- backend/main.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/main.py b/backend/main.py index e4e79e26b..d2d79d2c0 100644 --- a/backend/main.py +++ b/backend/main.py @@ -118,6 +118,14 @@ app.state.MODELS = {} origins = ["*"] +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + # Custom middleware to add security headers # class SecurityHeadersMiddleware(BaseHTTPMiddleware): @@ -221,15 +229,6 @@ class RAGMiddleware(BaseHTTPMiddleware): app.add_middleware(RAGMiddleware) -app.add_middleware( - CORSMiddleware, - allow_origins=origins, - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], -) - - @app.middleware("http") async def check_url(request: Request, call_next): if len(app.state.MODELS) == 0: