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 import FastAPI
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from app.routes import router
|
from app.routes import router
|
||||||
|
from constants import origins
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
app.include_router(router)
|
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 import APIRouter, Depends
|
||||||
from fastapi.security import OAuth2PasswordBearer
|
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app.external_services import resend_otp, send_otp
|
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()
|
router = APIRouter()
|
||||||
|
|
||||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/register", response_model=UserCreateResponse)
|
@router.post("/register", response_model=UserCreateResponse)
|
||||||
def create_user(data: UserCreate, db: Session = Depends(get_db)):
|
def add_user(data: UserCreate, db: Session = Depends(get_db)):
|
||||||
user = add_user(data=data, db=db)
|
user = create_user(data=data, db=db)
|
||||||
send_otp(data=user, db=db)
|
send_otp(data=user, db=db)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ mkShell {
|
||||||
python38Packages.alembic
|
python38Packages.alembic
|
||||||
python38Packages.pytest
|
python38Packages.pytest
|
||||||
python38Packages.twilio
|
python38Packages.twilio
|
||||||
|
python38Packages.cryptography
|
||||||
python38Packages.passlib
|
python38Packages.passlib
|
||||||
python38Packages.bcrypt
|
python38Packages.bcrypt
|
||||||
sqlite
|
sqlite
|
||||||
|
|
Loading…
Reference in New Issue