Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litellm/proxy/_experimental/mcp_server/oauth_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_request_base_url(request: Request) -> str:
if x_forwarded_port and ":" not in netloc:
netloc = f"{netloc}:{x_forwarded_port}"

return urlunparse((scheme, netloc, parsed.path, "", "", ""))
return urlunparse((scheme, _strip_default_port(scheme, netloc), parsed.path, "", "", ""))


def validate_loopback_redirect_uri(redirect_uri: str) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,41 @@ async def test_token_endpoint_respects_x_forwarded_host():
None,
"https://external.com",
),
(
"http://localhost:4000/",
"https",
"proxy.example.com",
"443",
"https://proxy.example.com",
),
(
"http://localhost:4000/",
"http",
"proxy.example.com",
"80",
"http://proxy.example.com",
),
(
"http://internal.local/",
"https",
None,
"443",
"https://internal.local",
),
(
"http://localhost:4000/",
"https",
"proxy.example.com",
"8443",
"https://proxy.example.com:8443",
),
(
"http://localhost:4000/",
"https",
"proxy.example.com:443",
None,
"https://proxy.example.com",
),
],
)
def test_get_request_base_url_comprehensive(
Expand Down
Loading