from fastapi import APIRouter, Response router = APIRouter() @router.get("/hello") def hello(response: Response): response.set_cookie(key="cookie1", value="value1") return {"message": "Hello, FastAPI with CORS!"}