This commit is contained in:
Qi Qi 2025-01-15 10:57:11 +08:00 committed by GitHub
commit 47290169c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -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 ||
"";

View File

@ -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);