You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Streamlit let's you configure --server.baseUrlPath=/username/appname when starting an app. It will be trickier with FastHTML as both the backend and the frontend need to know about this, but I think it can be done with a settings / environment variable.
Example code
I was able to get this mostly working by manually wrapping the app in a custom entrypoint and adding some headers to the generated HTML:
This would allow users to host multiple apps on a single domain behind an authenticated proxy. It also enables 3rd parties to support hosting fasthtml apps within their existing platforms.
Additional context
I imagine my initial approach doesn't catch all cases. For instance I noticed when live=True the websocket is not getting re-routed when I mounted the existing Starlette app. The <base href tag should take care of any vanilla links that are relative. HTMX doesn't respect that tag so I added the configRequest hook. If users incorporate their own weird routing or custom JS it might be nice to expose something on the window object so they could use it... It's a bit of a rabbit hole but making the simple case work still seems worth it.
Confirmation
Please confirm the following:
I have checked the existing issues and pull requests to ensure this feature hasn't been requested before.
I have read the project's documentation to ensure this feature doesn't already exist.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I want to run FastHTML application's within my existing web app under a dynamic url prefix. For example: https://apps.aihype.com/username/appname.
Describe the solution you'd like
Streamlit let's you configure
--server.baseUrlPath=/username/appname
when starting an app. It will be trickier with FastHTML as both the backend and the frontend need to know about this, but I think it can be done with a settings / environment variable.Example code
I was able to get this mostly working by manually wrapping the app in a custom entrypoint and adding some headers to the generated HTML:
Wrapper
App
Similar implementations
baseUrlPath
in the Server sectionProblem solved
This would allow users to host multiple apps on a single domain behind an authenticated proxy. It also enables 3rd parties to support hosting fasthtml apps within their existing platforms.
Additional context
I imagine my initial approach doesn't catch all cases. For instance I noticed when
live=True
the websocket is not getting re-routed when I mounted the existing Starlette app. The<base href
tag should take care of any vanilla links that are relative. HTMX doesn't respect that tag so I added theconfigRequest
hook. If users incorporate their own weird routing or custom JS it might be nice to expose something on the window object so they could use it... It's a bit of a rabbit hole but making the simple case work still seems worth it.Confirmation
Please confirm the following:
The text was updated successfully, but these errors were encountered: