fix(admins.tsx): fix logic for getting base url and create common get base url component (#7854)

Resolves https://github.com/BerriAI/litellm/issues/7761
This commit is contained in:
Krish Dholakia 2025-01-18 08:07:39 -08:00 committed by GitHub
parent 00594871a4
commit 762d872b7e
5 changed files with 26 additions and 19 deletions

View file

@ -42,6 +42,8 @@ interface AdminPanelProps {
showSSOBanner: boolean;
premiumUser: boolean;
}
import { useBaseUrl } from "./constants";
import {
userUpdateUserCall,
@ -94,18 +96,11 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
if (isLocal != true) {
console.log = function() {};
}
const [baseUrl, setBaseUrl] = useState(
isLocal ? "http://localhost:4000" : ""
);
const baseUrl = useBaseUrl();
const all_ip_address_allowed = "All IP Addresses Allowed";
let nonSssoUrl;
try {
nonSssoUrl = window.location.origin;
} catch (error) {
nonSssoUrl = "<your-proxy-url>";
}
let nonSssoUrl = baseUrl;
nonSssoUrl += "/fallback/login";
const handleShowAllowedIPs = async () => {
@ -202,13 +197,13 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
const roles = ["proxy_admin", "proxy_admin_viewer"];
useEffect(() => {
if (router) {
const { protocol, host } = window.location;
const baseUrl = `${protocol}//${host}`;
setBaseUrl(baseUrl);
}
}, [router]);
// useEffect(() => {
// if (router) {
// const { protocol, host } = window.location;
// const baseUrl = `${protocol}//${host}`;
// setBaseUrl(baseUrl);
// }
// }, [router]);
useEffect(() => {
// Fetch model info and set the default selected model