mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(ui): disable /config/list fetch in useProxyConfig for non-admin users
The useProxyConfig hook called GET /config/list unconditionally on mount, regardless of user role. Since /config/list is admin-only (returns 400 for non-admin), every page load for internal_user sessions generated a 400 error log entry. Add isProxyAdminRole check to the query's enabled flag so the fetch is skipped entirely for non-admin users. The isProxyAdminRole utility already exists in @/utils/roles. Fixes #24309
This commit is contained in:
parent
d7c419bfee
commit
5fc83d90bf
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { useQuery, useMutation, UseMutationResult } from "@tanstack/react-query";
|
||||
import { createQueryKeys } from "../common/queryKeysFactory";
|
||||
import useAuthorized from "../useAuthorized";
|
||||
import { isProxyAdminRole } from "@/utils/roles";
|
||||
import { proxyBaseUrl, getGlobalLitellmHeaderName, deriveErrorMessage, handleError } from "@/components/networking";
|
||||
|
||||
/**
|
||||
|
|
@ -146,7 +147,7 @@ export const deleteProxyConfigFieldCall = async (
|
|||
* @returns React Query result with the config list data
|
||||
*/
|
||||
export const useProxyConfig = (configType: ConfigType) => {
|
||||
const { accessToken } = useAuthorized();
|
||||
const { accessToken, userRole } = useAuthorized();
|
||||
return useQuery<ProxyConfigResponse>({
|
||||
queryKey: proxyConfigKeys.list({
|
||||
filters: {
|
||||
|
|
@ -154,7 +155,7 @@ export const useProxyConfig = (configType: ConfigType) => {
|
|||
},
|
||||
}),
|
||||
queryFn: async () => await getProxyConfigCall(accessToken!, configType),
|
||||
enabled: Boolean(accessToken),
|
||||
enabled: Boolean(accessToken) && isProxyAdminRole(userRole ?? ""),
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue