-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register middlewares as late as possible (#4155)
This PR moves the middleware registration from import time to the actual call of `ui.run`. Thereby the middlewares are also run before middlewares which are added by user code. See the the authentication example for an actual use-case where this is convinient: https://github.com/zauberzeug/nicegui/blob/09f4c34049b37907174bfe3109aae4b834f80863/examples/authentication/main.py#L28C2-L33C40 Without this change, the `RedirectResponse` does not work properly behind a reverse proxy with subpath or NiceGUI On Air, because the rewriting of the path prefix which is done by our `RedirectWithPrefixMiddleware`. FastAPI / Starlette call the middlewares in reverse order of registration. Therefore, without this PR, the user middleware is the last one added and hence called first, leaving the path unmodified. ToDos: - [x] test with simple NiceGUI App which has no `if __name__ in ('__mp_main__', '__main__')` guard - [x] implement and test `ui.run_with` --------- Co-authored-by: Falko Schindler <falko@zauberzeug.com>
- Loading branch information
1 parent
e6fa211
commit 6140d10
Showing
3 changed files
with
9 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters