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
Use x-forwarded-host
header to determine the root url, and let users provide a full root_path
to override the automatically determined root url
#7641
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/3f6ced361dfac11fe1545fb16ae643f1e93e0af1/gradio-4.20.1-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@3f6ced361dfac11fe1545fb16ae643f1e93e0af1#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
x-forwarded-host
header, and let users provide a full root_url
to override the automatically determined root url
x-forwarded-host
header, and let users provide a full root_url
to override the automatically determined root urlx-forwarded-host
header to determine the root url, and let users provide a full root_path
to override the automatically determined root url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix @abidlabs !
Thanks a bunch for the review @freddyaboulton |
This PR fixes the issue that we're seeing where Gradio apps don't render properly on k8 environments and some other places where the URL of the Gradio app is behind an app router or proxy.
The fix is to look at the
x-forwarded-host
header, if available, and use that in place of the request URL, as this header points to the public URL of the Gradio app.In addition, we provide users with a fallback in case Gradio is not able to determine the root url automatically. By providing a full
root_path
(either as an env variable or as a parameter inlaunch()
), users can set their own root url, which takes precedence over the one Gradio constructs automatically.Closes: #7317