web/lib/api: return errors from authorization function

This commit is contained in:
wukko 2024-11-24 13:37:36 +06:00
parent 6bb412852d
commit d8f3bbe0f3
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -41,8 +41,6 @@ const getAuthorization = async () => {
if (processing.enableCustomApiKey && processing.customApiKey.length > 0) { if (processing.enableCustomApiKey && processing.customApiKey.length > 0) {
return `Api-Key ${processing.customApiKey}`; return `Api-Key ${processing.customApiKey}`;
} }
return false;
} }
const request = async (url: string) => { const request = async (url: string) => {
@ -86,7 +84,11 @@ const request = async (url: string) => {
const api = currentApiURL(); const api = currentApiURL();
const authorization = await getAuthorization(); const authorization = await getAuthorization();
let extraHeaders = {} if (authorization && typeof authorization !== "string") {
return authorization;
}
let extraHeaders = {};
if (authorization) { if (authorization) {
extraHeaders = { extraHeaders = {