Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`adk web --url_prefix` doesn't fix /docs and /openapi.json behind a reverse proxy

オープン
#7,070 コメント 3 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@surajksharma07 がすでに取り組んでいます。

2026年9月9日 から。

評価

この issue はまだ評価されていません。

説明

request clarification web

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:

  1. Setting backendUrl in the dev-ui's runtime-config.json.
  2. 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

  1. Run adk web --url_prefix /agents/myagent ... (or a full URL, as some deployments pass an absolute backend URL here).
  2. 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 /).
  3. Visit https://host/agents/myagent/docs.
  4. Swagger UI loads, but its embedded fetch of /openapi.json resolves against the bare domain root (https://host/openapi.json), not https://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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/adk-python のほかの issue

google/adk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。