mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-05 08:07:05 +00:00
Merge pull request #32921 from BerriAI/litellm_lit4126_default_port_strip
fix(mcp): strip scheme default port from get_request_base_url netloc
This commit is contained in:
commit
9659ae2f40
2 changed files with 36 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue