diff --git a/main.py b/main.py index 45c814c..2543508 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ from typing import Dict from model import MongoDB from model.ResponseType import ChartResponse, GenderInfo, PartyInfo, AgeInfo - +from fastapi.middleware.cors import CORSMiddleware @asynccontextmanager async def initMongo(app: FastAPI): @@ -18,6 +18,18 @@ async def initMongo(app: FastAPI): app = FastAPI(lifespan=initMongo, responses={404: {"description": "Not found"}}) +origin = [ + "http://localhost:5173", + "https://diversity.tech4impact.kr/" +] + +app.add_middleware( + CORSMiddleware, + allow_origins=origin, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) app.include_router(scrapResult.router) app.include_router(commonInfo.router)