backend: CORS Support
This commit is contained in:
parent
d4921043c2
commit
9df2ee08d2
1 changed files with 12 additions and 0 deletions
|
|
@ -10,12 +10,24 @@ from .auth import (
|
||||||
create_access_token, get_password_hash,
|
create_access_token, get_password_hash,
|
||||||
)
|
)
|
||||||
from fastapi.security import OAuth2PasswordRequestForm
|
from fastapi.security import OAuth2PasswordRequestForm
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
app = FastAPI(title="Server Worklog")
|
app = FastAPI(title="Server Worklog")
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["*"], # oder deine echte Domain
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
# Nur für lokale Entwicklung, in Produktion via Alembic
|
# Nur für lokale Entwicklung, in Produktion via Alembic
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
|
@app.options("/{path:path}")
|
||||||
|
def preflight_handler(path: str):
|
||||||
|
return {}
|
||||||
|
|
||||||
@app.post("/auth/register", response_model=schemas.UserRead)
|
@app.post("/auth/register", response_model=schemas.UserRead)
|
||||||
def register_user(user_in: schemas.UserCreate, db: Session = Depends(get_db)):
|
def register_user(user_in: schemas.UserCreate, db: Session = Depends(get_db)):
|
||||||
existing = db.query(models.User).filter(models.User.username == user_in.username).first()
|
existing = db.query(models.User).filter(models.User.username == user_in.username).first()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue