Skip to content

Commit 9e45619

Browse files
authored
Merge pull request #4027 from BerriAI/litellm_fix_redirecting_base_url_set
[FIX] Proxy redirect to `PROXY_BASE_URL/ui` after logging in
2 parents 0d3e523 + b682597 commit 9e45619

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

litellm/proxy/utils.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -2709,13 +2709,15 @@ def decrypt_value(value: bytes, master_key: str) -> str:
27092709

27102710

27112711
# LiteLLM Admin UI - Non SSO Login
2712-
html_form = """
2712+
url_to_redirect_to = os.getenv("PROXY_BASE_URL", "")
2713+
url_to_redirect_to += "/login"
2714+
html_form = f"""
27132715
<!DOCTYPE html>
27142716
<html>
27152717
<head>
27162718
<title>LiteLLM Login</title>
27172719
<style>
2718-
body {
2720+
body {{
27192721
font-family: Arial, sans-serif;
27202722
background-color: #f4f4f4;
27212723
margin: 0;
@@ -2724,42 +2726,42 @@ def decrypt_value(value: bytes, master_key: str) -> str:
27242726
justify-content: center;
27252727
align-items: center;
27262728
height: 100vh;
2727-
}
2729+
}}
27282730
2729-
form {
2731+
form {{
27302732
background-color: #fff;
27312733
padding: 20px;
27322734
border-radius: 8px;
27332735
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
2734-
}
2736+
}}
27352737
2736-
label {
2738+
label {{
27372739
display: block;
27382740
margin-bottom: 8px;
2739-
}
2741+
}}
27402742
2741-
input {
2743+
input {{
27422744
width: 100%;
27432745
padding: 8px;
27442746
margin-bottom: 16px;
27452747
box-sizing: border-box;
27462748
border: 1px solid #ccc;
27472749
border-radius: 4px;
2748-
}
2750+
}}
27492751
2750-
input[type="submit"] {
2752+
input[type="submit"] {{
27512753
background-color: #4caf50;
27522754
color: #fff;
27532755
cursor: pointer;
2754-
}
2756+
}}
27552757
2756-
input[type="submit"]:hover {
2758+
input[type="submit"]:hover {{
27572759
background-color: #45a049;
2758-
}
2760+
}}
27592761
</style>
27602762
</head>
27612763
<body>
2762-
<form action="/login" method="post">
2764+
<form action="{url_to_redirect_to}" method="post">
27632765
<h2>LiteLLM Login</h2>
27642766
27652767
<p>By default Username is "admin" and Password is your set LiteLLM Proxy `MASTER_KEY`</p>
@@ -2771,8 +2773,6 @@ def decrypt_value(value: bytes, master_key: str) -> str:
27712773
<input type="password" id="password" name="password" required>
27722774
<input type="submit" value="Submit">
27732775
</form>
2774-
</body>
2775-
</html>
27762776
"""
27772777

27782778

0 commit comments

Comments
 (0)