Skip to content

Commit

Permalink
Add: CORS middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Nov 22, 2023
1 parent d14b531 commit 781af76
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

0 comments on commit 781af76

Please sign in to comment.