CORS Middleware
- class smarter.lib.django.middleware.cors.SmarterCorsMiddleware(get_response)[source]
Bases:
CorsMiddleware,SmarterHelperMixinCORS middleware that applies
django-cors-headersonly whileENABLE_MIDDLEWARE_CORSis on.Design rules:
no shared request state on self
no coroutine guessing in core logic
one class for sync and async mode
The allowed origins come from the
CORS_*Django settings, throughcorsheaders.middleware.CorsMiddleware. In sync mode, an amnesty path skips the middleware too.Example
To enable this middleware, add it to your Django project’s middleware settings:
MIDDLEWARE = [ ... 'smarter.lib.django.middleware.cors.SmarterCorsMiddleware', ... ]