forked from boos/BoosAPI
fix(proxy): apply account-level proxy to count_tokens and completions routes
This commit is contained in:
@@ -839,7 +839,7 @@ async function handleClaudeCountTokensRequest(
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: requestForFetch.headers,
|
headers: requestForFetch.headers,
|
||||||
body: JSON.stringify(requestForFetch.body),
|
body: JSON.stringify(requestForFetch.body),
|
||||||
}),
|
}, resolveChannelProxyUrl(selected.site, selected.account.extraConfig)),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (upstream.status === 401 && oauth) {
|
if (upstream.status === 401 && oauth) {
|
||||||
@@ -859,7 +859,7 @@ async function handleClaudeCountTokensRequest(
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: requestForFetch.headers,
|
headers: requestForFetch.headers,
|
||||||
body: JSON.stringify(requestForFetch.body),
|
body: JSON.stringify(requestForFetch.body),
|
||||||
}),
|
}, resolveChannelProxyUrl(selected.site, selected.account.extraConfig)),
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
// Fall through to the regular upstream error handling below.
|
// Fall through to the regular upstream error handling below.
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export async function completionsProxyRoute(app: FastifyInstance) {
|
|||||||
'Authorization': `Bearer ${selected.tokenValue}`,
|
'Authorization': `Bearer ${selected.tokenValue}`,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(forwardBody),
|
body: JSON.stringify(forwardBody),
|
||||||
}));
|
}, getProxyUrlFromExtraConfig(selected.account.extraConfig)));
|
||||||
|
|
||||||
if (!upstream.ok) {
|
if (!upstream.ok) {
|
||||||
const errText = await upstream.text().catch(() => 'unknown error');
|
const errText = await upstream.text().catch(() => 'unknown error');
|
||||||
|
|||||||
Reference in New Issue
Block a user