Skip to content

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 Dec 25, 2023
1 parent a4cb859 commit 422d70d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ const serverConfig = getServerSideConfig();
export async function requestOpenai(req: NextRequest) {
const controller = new AbortController();

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

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

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

0 comments on commit 422d70d

Please sign in to comment.