-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application root_path not working as it gets discarded by configure_app #9788
Comments
Hi, does this also happen when you do |
When using I think that |
Thanks for your reply! Also, I haven't tried yet, so I have to confirm this, but it seems to me that the implementation of |
Describe the bug
The
root_path
setting is necessary to serve FastAPI applications under subpaths served via a proxy and the ASGI frameworks are expected to strip it from the request path during the routing process, see django/asgiref#229 (comment)But Gradio currently doesn't handle
root_path
correctly when set viacreate_app
thus making very hard to serve Gradio applications mounted in subpaths. This is probably related to #8073 #9101 and #9529When creating a Gradio application, it accepts additional options that are
forwarded to the FastAPI application. This happens at
https://github.com/gradio-app/gradio/blob/main/gradio/routes.py#L236
and is correctly exposed via the
create_app
factoryhttps://github.com/gradio-app/gradio/blob/main/gradio/routes.py#L342
But when trying to serve Gradio under subpath, setting the
root_path
via
create_app
doesn't seem to do anything:The
root_path
is actually unset independently from the value provided,this is caused by the
configure_app
method invoked by thecreate_app
factory: https://github.com/gradio-app/gradio/blob/main/gradio/routes.py#L345
The
configure_app
overwrites the applicationroot_path
with whateverroot_path
the mounted block has (which is empty), thus making theroot_path
settingpointless: https://github.com/gradio-app/gradio/blob/main/gradio/routes.py#L298
Have you searched existing issues? 🔎
Reproduction
with following NGinx configuration
(the same configuration works correctly if it's a FastAPI application instead of a Gradio application)
Screenshot
No response
Logs
No response
System Info
Severity
Blocking usage of gradio
The text was updated successfully, but these errors were encountered: