Skip to content

Commit

Permalink
Compatible for getting auth token from client
Browse files Browse the repository at this point in the history
  • Loading branch information
timqi committed Dec 6, 2024
1 parent 83cea3a commit 54080c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 54080c0

Please sign in to comment.