fix fastapi middleware swallowing user routes bodies#3805
Conversation
| prefix = self.dash_app.config.routes_pathname_prefix | ||
| if "_dash-" not in path and path != prefix and path != prefix.rstrip("/"): | ||
| await self.app(scope, receive, send) | ||
| return |
There was a problem hiding this comment.
Returning here skips _run_before_hooks and _run_after_hooks. Is that intentional? You could move the check inside the try/except block and only call _setup_timing if it's a Dash route.
There was a problem hiding this comment.
Yes intentional, those are only for emulating the flask api for the dash setup, not intended for the user to use.
| # Non-Dash routes pass through to avoid consuming body stream | ||
| path = scope["path"] | ||
| prefix = self.dash_app.config.routes_pathname_prefix | ||
| if "_dash-" not in path and path != prefix and path != prefix.rstrip("/"): |
There was a problem hiding this comment.
This would match a path like "_dash-my-awesome-path", which would be a false positive. It might be worth making this check a bit more specific. Though it seems like no one would actually do this.
There was a problem hiding this comment.
Yea better put the prefix and startwith check. Other it could catch some random route like /my_dash-favorite
|



Fixes #3801