Fix Authorization header when not using a proxy
Some checks failed
Release Mikupad / build (push) Has been cancelled

This commit is contained in:
lmg-anon 2025-11-17 14:12:58 -03:00
parent 0c678ed74e
commit 4e4b21a024

View file

@ -1515,7 +1515,7 @@ async function llamaCppTokenCount({ endpoint, endpointAPIKey, proxyEndpoint, sig
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(endpointAPIKey ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : {}),
...(endpointAPIKey ? (proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }) : {}),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify(options),
@ -1532,7 +1532,7 @@ async function llamaCppTokenize({ endpoint, endpointAPIKey, proxyEndpoint, signa
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(endpointAPIKey ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : {}),
...(endpointAPIKey ? (proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }) : {}),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify(options),
@ -1561,7 +1561,7 @@ async function llamaCppDetokenize({ endpoint, endpointAPIKey, proxyEndpoint, sig
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(endpointAPIKey ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : {}),
...(endpointAPIKey ? (proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }) : {}),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify(options),
@ -1578,7 +1578,7 @@ async function* llamaCppCompletion({ endpoint, endpointAPIKey, proxyEndpoint, si
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(endpointAPIKey ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : {}),
...(endpointAPIKey ? (proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }) : {}),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({
@ -1639,7 +1639,7 @@ async function koboldCppTokenCount({ endpoint, endpointAPIKey, proxyEndpoint, si
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(endpointAPIKey ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : {}),
...(endpointAPIKey ? (proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }) : {}),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({
@ -1658,7 +1658,7 @@ async function koboldCppTokenize({ endpoint, endpointAPIKey, proxyEndpoint, sign
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(endpointAPIKey ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : {}),
...(endpointAPIKey ? (proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }) : {}),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({
@ -1706,7 +1706,7 @@ async function* koboldCppCompletion({ endpoint, endpointAPIKey, proxyEndpoint, s
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(endpointAPIKey ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : {}),
...(endpointAPIKey ? (proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }) : {}),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({
@ -1769,7 +1769,7 @@ async function openaiAphroditeTokenCount({ endpoint, endpointAPIKey, proxyEndpoi
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Real-Authorization': `Bearer ${endpointAPIKey}`,
...(proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({
@ -1814,7 +1814,7 @@ async function openaiTabbyTokenCount({ endpoint, endpointAPIKey, proxyEndpoint,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Real-Authorization': `Bearer ${endpointAPIKey}`,
...(proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({
@ -1948,7 +1948,7 @@ async function openaiModels({ endpoint, endpointAPIKey, proxyEndpoint, signal, .
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-Real-Authorization': `Bearer ${endpointAPIKey}`,
...(proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
signal,
@ -2023,7 +2023,7 @@ async function* openaiCompletion({ endpoint, endpointAPIKey, proxyEndpoint, sign
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Real-Authorization': `Bearer ${endpointAPIKey}`,
...(proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({
@ -2155,7 +2155,7 @@ async function* openaiChatCompletion({ endpoint, endpointAPIKey, proxyEndpoint,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Real-Authorization': `Bearer ${endpointAPIKey}`,
...(proxyEndpoint ? { 'X-Real-Authorization': `Bearer ${endpointAPIKey}` } : { 'Authorization': `Bearer ${endpointAPIKey}` }),
...(proxyEndpoint ? { 'X-Real-URL': endpoint } : {})
},
body: JSON.stringify({