fix(anthropic-compatible): send Bearer auth for third-party gateways
Third-party Anthropic-compatible gateways that require Authorization: Bearer (in addition to x-api-key) returned 401 missing_api_key on the forward path. For non-official upstreams, also send Bearer <apiKey> alongside x-api-key. Official api.anthropic.com behavior is unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -157,6 +157,12 @@ export class DefaultExecutor extends BaseExecutor {
|
|||||||
const baseUrl = credentials?.providerSpecificData?.baseUrl || "";
|
const baseUrl = credentials?.providerSpecificData?.baseUrl || "";
|
||||||
const isOfficialAnthropic = baseUrl === "" || baseUrl.includes("api.anthropic.com");
|
const isOfficialAnthropic = baseUrl === "" || baseUrl.includes("api.anthropic.com");
|
||||||
if (!isOfficialAnthropic) {
|
if (!isOfficialAnthropic) {
|
||||||
|
// Some third-party Anthropic-compatible gateways require Bearer auth in
|
||||||
|
// addition to x-api-key. Send both (x-api-key already set above) so
|
||||||
|
// gateways that read either header succeed.
|
||||||
|
if (credentials.apiKey && !headers["Authorization"]) {
|
||||||
|
headers["Authorization"] = `Bearer ${credentials.apiKey}`;
|
||||||
|
}
|
||||||
delete headers["anthropic-dangerous-direct-browser-access"];
|
delete headers["anthropic-dangerous-direct-browser-access"];
|
||||||
delete headers["Anthropic-Dangerous-Direct-Browser-Access"];
|
delete headers["Anthropic-Dangerous-Direct-Browser-Access"];
|
||||||
delete headers["x-app"];
|
delete headers["x-app"];
|
||||||
|
|||||||
Reference in New Issue
Block a user