`adk web --url_prefix` doesn't fix /docs and /openapi.json behind a reverse proxy
メンテナーはふだん 1 日以内に返信
@surajksharma07 がすでに取り組んでいます。
2026年9月9日 から。
評価
この issue はまだ評価されていません。
説明
Description
When running adk web behind a reverse proxy that mounts the app under a path prefix (e.g. https://host/agents/myagent/...), the --url_prefix flag is documented as fixing exactly this case:
Optional. URL path prefix when the application is mounted behind a reverse proxy or API gateway (e.g., '/api/v1', '/adk'). This ensures generated URLs and redirects work correctly when the app is not served at the root path.
In practice, url_prefix is currently only used for two things in api_server.py:
- Setting
backendUrlin the dev-ui'sruntime-config.json. - Building the
/dev-ui/redirect target.
It is never passed to the underlying FastAPI app as root_path. Since FastAPI(lifespan=internal_lifespan) is constructed with no root_path, Starlette generates docs_url/openapi_url and other reverse-generated URLs assuming the app is served at /.
Repro
- Run
adk web --url_prefix /agents/myagent ...(or a full URL, as some deployments pass an absolute backend URL here). - Put the app behind a proxy that forwards
https://host/agents/myagent/*to the pod, stripping the prefix before it reaches the app (so the app itself sees requests at/). - Visit
https://host/agents/myagent/docs. - Swagger UI loads, but its embedded fetch of
/openapi.jsonresolves against the bare domain root (https://host/openapi.json), nothttps://host/agents/myagent/openapi.json— so it 404s (or worse, hits an unrelated service sharing that domain).
Suggested fix
Derive the FastAPI root_path from url_prefix and pass it into the FastAPI(...) constructor. url_prefix can be either a bare path or a full absolute URL (in our deployment we pass a full URL, since it's reused as the frontend's absolute backendUrl), so extracting just the path component via urllib.parse.urlparse(url_prefix).path handles both cases.
I've opened a draft PR with this fix: (link added below once created)
Happy to adjust the approach (e.g. supporting X-Forwarded-Prefix as a runtime alternative) if that's preferred over a startup-time flag.
- 主要言語
- Python
- スター
- 21.6k
- フォーク
- 4k
- 平均マージ
- 12時間 6分
- マージ済み PR(30日)
- 4
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/adk-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
google/adk-python#7298 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
google/adk-python#7292 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
google/adk-python#7289 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/adk-python#7282 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
CredentialsManager should also extract scopes when populating auth schemes対応中かも @sanketpatil06 が 2 日前に担当しました。 オープンcore needs review
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/adk-python#7266 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
google/adk-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
PedestrianDynamics/pyFDS-Evac#199 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
521xueweihan/HelloGitHub#3790 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sandialabs/atlas-ui-3#978 ·
メンテナーはふだん 1 日以内に返信
-
area: tests perceived difficulty: 2
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Nitjsefnie-Harness-Commons/daedalus#1255 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
EleutherAI/lm-evaluation-harness#4256 ·
メンテナーはふだん 1 日以内に返信