Add CORS middleware
This commit is contained in:
13
app/main.py
13
app/main.py
@@ -2,6 +2,7 @@ import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
import os
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from contextlib import asynccontextmanager
|
||||
from dotenv import load_dotenv
|
||||
@@ -37,7 +38,19 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
|
||||
origins = [
|
||||
"http://127.0.0.1",
|
||||
"http://localhost",
|
||||
"http://localhost:8080",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["GET" "PUT" "POST" "DELETE" "PATCH"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(token_router)
|
||||
app.include_router(userManager.user_router)
|
||||
|
||||
Reference in New Issue
Block a user