from starlette.types import Receive, Scope, Send from starlette_csrf.middleware import CSRFMiddleware class CustomCSRFMiddleware(CSRFMiddleware): async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: if scope["type"] != "http": await self.app(scope, receive, send) return await super().__call__(scope, receive, send)