FastAPI · Class
CORSMiddleware
CORSMiddleware controls which browser origins can call a FastAPI app. Configure allowed origins, methods, headers, and credentials for cross-origin requests.
Last updated
Syntax
CORSMiddleware(app, allow_origins=(), allow_methods=("GET",), allow_headers=(), allow_credentials=False, allow_origin_regex=None, allow_private_network=False, expose_headers=(), max_age=600)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
FastAPIapp.add_middleware()ASGI middlewareStarletteCORS