Switch from root_url to request.url in get_api_call_path() (#10877)

* changes

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Abubakar Abid 2025-03-25 14:15:56 -04:00 committed by GitHub
parent 3a3d0d9388
commit b19e8ad267
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
feat:Switch from `root_url` to `request.url` in `get_api_call_path()`

View File

@ -384,17 +384,16 @@ def get_api_call_path(request: fastapi.Request) -> str:
"""
queue_api_url = f"{API_PREFIX}/queue/join"
generic_api_url = f"{API_PREFIX}/call"
request_url = str(request.url)
root_url = get_request_url(request)
if root_url.endswith(queue_api_url):
if request_url.endswith(queue_api_url):
return queue_api_url
start_index = root_url.rfind(generic_api_url)
start_index = request_url.rfind(generic_api_url)
if start_index >= 0:
return root_url[start_index : len(root_url)]
return request_url[start_index : len(request_url)]
raise ValueError(f"Request url '{root_url}' has an unkown api call pattern.")
raise ValueError(f"Request url '{request_url}' has an unkown api call pattern.")
def get_root_url(