`adk web --url_prefix` doesn't fix /docs and /openapi.json behind a reverse proxy
@surajksharma07 đang làm issue này rồi.
Từ ngày 9/9/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 21.6k
- Fork
- 4k
- Merge trung bình
- 13 giờ 49 phút
- Pull request đã merge (30 ngày)
- 10
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/adk-python
-
mcp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
google/adk-python#7217 · 3 bình luận · 1 người được giao ·
-
tools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
google/adk-python#7206 · 1 bình luận · 1 người được giao ·
-
request clarification tools
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
google/adk-python#7205 · 2 bình luận · 1 người được giao ·
-
mcp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
google/adk-python#7196 · 1 bình luận · 1 người được giao ·
-
eval request clarification
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 86/100
google/adk-python#7146 · 2 bình luận · 1 người được giao ·
Tất cả issue của google/adk-python
Issue tương tự
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
[Feature] 奇物选择添加优先级 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
syfoud/Simulated_Scepter#174 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Giskard-AI/giskard-oss#2840 · 1 bình luận ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Đang mởarea: repo bug perceived difficulty: 2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·