Skip to content
masterclass Buddy

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.

Subscribe
  • FastAPI
  • app.add_middleware()
  • ASGI middleware
  • Starlette
  • CORS

Source: CORS (Cross-Origin Resource Sharing) - FastAPI. Checked 2026-11-03.