From a6f524680ce04b2c14ca3554165b9ef8ba664c94 Mon Sep 17 00:00:00 2001 From: ishaan-jaff Date: Wed, 31 Jan 2024 20:22:22 -0800 Subject: [PATCH] (fix) UI Proxy - handle base url ending with / --- litellm/proxy/proxy_server.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 51b54f2d24a..2be043c9a4d 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -3171,23 +3171,21 @@ async def auth_callback(request: Request): param="PROXY_BASE_URL", code=status.HTTP_500_INTERNAL_SERVER_ERROR, ) - if proxy_base_url.endswith("/"): - proxy_base_url += "ui" - else: - proxy_base_url += "/ui" + litellm_dashboard_ui = proxy_base_url + if proxy_base_url.endswith("/"): + litellm_dashboard_ui += "ui" + proxy_base_url = proxy_base_url[:-1] + else: + litellm_dashboard_ui += "/ui" + import jwt jwt_token = jwt.encode( {"user_id": user_id, "key": key}, "secret", algorithm="HS256" ) litellm_dashboard_ui += ( - "?userID=" - + user_id - + "&token=" - + jwt_token - + "&proxyBaseUrl=" - + os.getenv("PROXY_BASE_URL") + "?userID=" + user_id + "&token=" + jwt_token + "&proxyBaseUrl=" + proxy_base_url ) # if a user has logged in they should be allowed to create keys - this ensures that it's set to True