diff --git a/app/api/anthropic.ts b/app/api/anthropic.ts index 7a44443710f..2473caa0ffa 100644 --- a/app/api/anthropic.ts +++ b/app/api/anthropic.ts @@ -62,8 +62,8 @@ async function request(req: NextRequest) { let authHeaderName = "x-api-key"; let authValue = - req.headers.get(authHeaderName) || req.headers.get("Authorization")?.replaceAll("Bearer ", "").trim() || + req.headers.get(authHeaderName) || serverConfig.anthropicApiKey || ""; diff --git a/app/api/auth.ts b/app/api/auth.ts index 6703b64bd15..86ec5a4d590 100644 --- a/app/api/auth.ts +++ b/app/api/auth.ts @@ -25,7 +25,8 @@ function parseApiKey(bearToken: string) { } export function auth(req: NextRequest, modelProvider: ModelProvider) { - const authToken = req.headers.get("Authorization") ?? ""; + const authToken = + req.headers.get("Authorization") ?? req.headers.get("x-api-key") ?? ""; // check if it is openai api key or user token const { accessCode, apiKey } = parseApiKey(authToken);