Skip to content

Commit

Permalink
fix: return bearer header when using openai
Browse files Browse the repository at this point in the history
  • Loading branch information
fredliang44 authored and jz1248 committed Jan 7, 2024
1 parent 259e924 commit 9690a10
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 9690a10

Please sign in to comment.