From 54080c0563a2c0cf4a10aa20dac032bfe70a048b Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 6 Dec 2024 12:31:21 +0800 Subject: [PATCH] Compatible for getting auth token from client --- app/api/auth.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/api/auth.ts b/app/api/auth.ts index 6703b64bd..86ec5a4d5 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);