From 49ff9182b4e3d4950407b35523dfac25646c8c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=9C=A4?= <77539625+pykido@users.noreply.github.com> Date: Fri, 19 Jul 2024 02:22:57 +0900 Subject: [PATCH] =?UTF-8?q?CORS=20=EC=84=A4=EC=A0=95=20=20(#128)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat : 지민이가 만든 RAG/LangChanin 활용하여 [경단챗봇 - 기사 API] 구현 * refactor : CORS 설정 완료 ! 모두 다 풀어줬음!! --- app/main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index e9fd22c..1254159 100644 --- a/app/main.py +++ b/app/main.py @@ -14,15 +14,25 @@ from app.router.send_email_service_router import send_email_service_router from app.router.user_type_router import user_type_router from app.service.news_scheduling_service import schedule_task +from fastapi.middleware.cors import CORSMiddleware app = FastAPI() +# CORS 설정 +origins = ["*"] # 모든 출처 허용 + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, # 모든 출처 허용 + allow_credentials=True, + allow_methods=["*"], # 모든 HTTP 메소드 허용 + allow_headers=["*"], # 모든 HTTP 헤더 허용 +) @app.on_event("startup") async def startup_event(): asyncio.create_task(schedule_task()) - # load env load_dotenv() @@ -40,7 +50,6 @@ async def startup_event(): app.add_exception_handler(Exception, exception_handler) app.add_exception_handler(HTTPException, http_exception_handler) - @app.get("/health") async def health_check(): return {"status": "OK"}