Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
chore: update auth value logic (ChatGPTNextWeb#3630)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredliang44 authored and H0llyW00dzZ committed Dec 26, 2023
1 parent 552ccac commit 190681e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ const serverConfig = getServerSideConfig();
export async function requestOpenai(req: NextRequest) {
const controller = new AbortController();

const authValue = req.headers.get("Authorization") ?? "";
const authHeaderName = serverConfig.isAzure ? "api-key" : "Authorization";
var authValue,
authHeaderName = "";
if (serverConfig.isAzure) {
authValue =
req.headers
.get("Authorization")
?.trim()
.replaceAll("Bearer ", "")
.trim() ?? "";

authHeaderName = "api-key";
} else {
authValue = req.headers.get("Authorization") ?? "";
authHeaderName = "Authorization";
}

let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(
"/api/openai/",
Expand Down

0 comments on commit 190681e

Please sign in to comment.