Skip to content

Commit

Permalink
feat: add cors middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
yaongmeow committed Jun 8, 2024
1 parent 654a9c3 commit bc2b5b4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions BE/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@
from routes.history import history_router
from routes.statistics import statistics_router
from middleware import authentication_check
from fastapi.middleware.cors import CORSMiddleware

from dotenv import load_dotenv
import os

origins = [
"*",
]

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
load_dotenv(os.path.join(BASE_DIR, ".env"))

app = FastAPI()

app.add_middleware(authentication_check)
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

app.include_router(auth_router, prefix="/auth")
app.include_router(footprint_router, prefix="/footprint")
Expand Down

0 comments on commit bc2b5b4

Please sign in to comment.