- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Fix reverse proxy #3347
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
base: main
Are you sure you want to change the base?
Fix reverse proxy #3347
Conversation
| Summary of ChangesHello @wyf7107, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces crucial functionality for deploying the 'adk web' application in environments utilizing reverse proxies. By adding a '--root_path' parameter, the application can now correctly construct URLs for its backend services and manage UI redirects, ensuring seamless operation when accessed via a proxied path rather than directly from its root. This enhancement improves deployment flexibility and compatibility with various network architectures. Highlights
 Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either  
 Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a  Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
 | 
| Response from ADK Triaging Agent Hello @wyf7107, thank you for creating this PR! To help reviewers evaluate your contribution, could you please provide the following information as outlined in our contribution guidelines? 
 Additionally, the  ./autoformat.shThis information will help reviewers to review your PR more efficiently. Thanks! | 
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.
Code Review
This pull request adds support for running the ADK web server behind a reverse proxy by introducing a --root_path parameter. The changes correctly propagate this new parameter through the CLI, FastAPI app setup, and to the web server logic. My review includes a few suggestions to improve code style, type safety, and robustness in URL construction. Overall, the implementation is solid and addresses the feature requirement effectively.
|  | ||
| devRedirectUrl = "/dev-ui/" | ||
| if self.root_path: | ||
| devRedirectUrl = self.root_path + "/dev-ui/" | 
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.
The current string concatenation for devRedirectUrl could result in a double slash (e.g., /proxy//dev-ui/) if self.root_path has a trailing slash. While many systems handle this, it's more robust to ensure a clean URL. Using rstrip('/') will prevent this issue.
| devRedirectUrl = self.root_path + "/dev-ui/" | |
| devRedirectUrl = self.root_path.rstrip("/") + "/dev-ui/" | 
| @click.option( | ||
| "--root_path", | ||
| type=str, | ||
| default = None, | 
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.
| a2a: bool = False, | ||
| host: str = "127.0.0.1", | ||
| port: int = 8000, | ||
| root_path = None, | 
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.
Add support for reverse proxy in adk web, users can specify a optional param
--root_pathfor the proxied path.