Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#3629 from fredliang44/main
Browse files Browse the repository at this point in the history
fix: return bearer header when using openai
  • Loading branch information
fredliang44 authored Dec 25, 2023
2 parents bd1e311 + 19137b7 commit a4cb859
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ const serverConfig = getServerSideConfig();
export async function requestOpenai(req: NextRequest) {
const controller = new AbortController();

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

let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(
Expand Down

0 comments on commit a4cb859

Please sign in to comment.