cors#

class starlite.middleware.cors.CORSMiddleware#

Bases: AbstractMiddleware

CORS Middleware.

__init__(app: ASGIApp, config: CORSConfig)#

Middleware that adds CORS validation to the application.

Parameters:
  • app – The next ASGI app to call.

  • config – An instance of CORSConfig

send_wrapper(send: Send, origin: str, has_cookie: bool) Send#

Wrap send to ensure that state is not disconnected.

Parameters:
  • has_cookie – Boolean flag dictating if the connection has a cookie set.

  • origin – The value of the Origin header.

  • send – The ASGI send function.

Returns:

An ASGI send function.