See the starlette issue as well as the limitations section of the documentation.
It seems like using BaseHTTPMiddleware breaks some things with async/background tasks in FastAPI and people generally recommend switching your middleware to be pure ASGI middleware for maximum compatibility.
Unfortunately, I've been noticing this issue ever since I integrated the supertokens middleware into my application.
See the starlette issue as well as the limitations section of the documentation.
It seems like using
BaseHTTPMiddlewarebreaks some things with async/background tasks in FastAPI and people generally recommend switching your middleware to be pure ASGI middleware for maximum compatibility.Unfortunately, I've been noticing this issue ever since I integrated the supertokens middleware into my application.