Set up Cross-Origin Resource Sharing (CORS)
This commit is contained in:
parent
eb56623bd4
commit
6bf2cba862
|
@ -1,5 +1,14 @@
|
|||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from app.routes import router
|
||||
from constants import origins
|
||||
|
||||
app = FastAPI()
|
||||
app.include_router(router)
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from fastapi import APIRouter, Depends
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.external_services import resend_otp, send_otp
|
||||
|
@ -8,12 +7,10 @@ from database.crud import add_user, get_db, verify_otp
|
|||
|
||||
router = APIRouter()
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
||||
|
||||
|
||||
@router.post("/register", response_model=UserCreateResponse)
|
||||
def create_user(data: UserCreate, db: Session = Depends(get_db)):
|
||||
user = add_user(data=data, db=db)
|
||||
def add_user(data: UserCreate, db: Session = Depends(get_db)):
|
||||
user = create_user(data=data, db=db)
|
||||
send_otp(data=user, db=db)
|
||||
return user
|
||||
|
||||
|
|
Loading…
Reference in New Issue