Issues ASGI mount
Hi! I've been exploring integrations with the ASGI mount. I keep hitting issues when trying more complex scenarios than the intro docs / examples.
It's hard to debug and introspect because a lot is bundled together, so I'm looking for some details:
- what is bundled via
create_asgi_app()
and what is required for the app to run? (e.g., do I need user_config_manager
?)
- I found marimo._server.api.router.build_routes()
but what is required / optional?
- handling file paths when mounting is challenging (cwd for launching the server vs. main app dir vs. marimo ASGI subapp dir vs. marimo notebook path)
- the redirect feature from create_redirect_to_slash()
adds misdirection and should be opt-in
- one potential source of challenge is the marimo app bundles HTTP, Websockets, and static files routes, but they might have different mount requirements for the main app (e.g., middlewares, conflicting paths)
solution
have a "core" ASGI app or set of routes with minimal features (no middleware, no LSP, no redirect) for developers. This would be in addition to the current "full ASGI app" that's more user-friendly
I really tried fixing this myself, and I'm willing to contribute, but would require some guidance on how to approach it5 Replies
Someone will reply to you shortly. In the meantime, this might help:
Issue with
create_redirect_to_slash()
Maybe it has something to do with marimo._server.start.start(base_url=...)
I think the redirect issue is related to https://github.com/marimo-team/marimo/issues/2938
GitHub
create_asgi_app: Marimo server mounted to non-root fails to fetch ...
The first GET request is successful but blank because it's looking for other resources in root path, not relative to where the app is mounted to. INFO: 10.91.2.13:5046 - "GET /marimo/motes...
i dont think there is any LSP. (or rather it is a noop).
as far as middleware, it is all the required middleware for the app to run. is there any that you'd like not included? we can make it configurable to remove them.
Thanks for the info! I agree with the linked issue that it relates to absolute / relative path and the mount point of the ASGI app.
I'll continue hacking around to mount Marimo routes individually to my main app and report back if I find a solution.