backend: CORS Support

This commit is contained in:
Frank Agerholm 2026-01-25 17:00:35 +01:00
commit 9df2ee08d2
No known key found for this signature in database

View file

@ -10,12 +10,24 @@ from .auth import (
create_access_token, get_password_hash,
)
from fastapi.security import OAuth2PasswordRequestForm
from fastapi.middleware.cors import CORSMiddleware
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
Base.metadata.create_all(bind=engine)
@app.options("/{path:path}")
def preflight_handler(path: str):
return {}
@app.post("/auth/register", response_model=schemas.UserRead)
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()