Skip to content

Commit

Permalink
Merge pull request #6 from NewWays-TechForImpactKAIST/cors-patch
Browse files Browse the repository at this point in the history
Add: CORS middleware
  • Loading branch information
happycastle114 authored Nov 22, 2023
2 parents ace8306 + 781af76 commit 3c426d0
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)
Expand Down

0 comments on commit 3c426d0

Please sign in to comment.