mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-05 08:10:30 +00:00
fix: prevent getOpenAIUrls and getOpenAIKeys crash on null response (#20272)
Use optional chaining and nullish coalescing when accessing res.OPENAI_API_BASE_URLS and res.OPENAI_API_KEYS. Returns empty array instead of crashing with 'Cannot read property of null'.
This commit is contained in:
parent
252a983091
commit
0bd295b10b
1 changed files with 2 additions and 2 deletions
|
|
@ -103,7 +103,7 @@ export const getOpenAIUrls = async (token: string = '') => {
|
|||
throw error;
|
||||
}
|
||||
|
||||
return res.OPENAI_API_BASE_URLS;
|
||||
return res?.OPENAI_API_BASE_URLS ?? [];
|
||||
};
|
||||
|
||||
export const updateOpenAIUrls = async (token: string = '', urls: string[]) => {
|
||||
|
|
@ -170,7 +170,7 @@ export const getOpenAIKeys = async (token: string = '') => {
|
|||
throw error;
|
||||
}
|
||||
|
||||
return res.OPENAI_API_KEYS;
|
||||
return res?.OPENAI_API_KEYS ?? [];
|
||||
};
|
||||
|
||||
export const updateOpenAIKeys = async (token: string = '', keys: string[]) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue