mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
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:
parent
2fdbcca9ae
commit
5d065c2c35
5 changed files with 26 additions and 19 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -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
|
||||
|
|
|
|||
15
ui/litellm-dashboard/src/components/constants.tsx
Normal file
15
ui/litellm-dashboard/src/components/constants.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// useBaseUrl.ts
|
||||
import { useState, useEffect } from 'react';
|
||||
|
||||
export const useBaseUrl = () => {
|
||||
const [baseUrl, setBaseUrl] = useState("http://localhost:4000");
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
const { protocol, host } = window.location;
|
||||
setBaseUrl(`${protocol}//${host}`);
|
||||
}
|
||||
}, []); // Removed router dependency
|
||||
|
||||
return baseUrl;
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue