Skip to content

Commit

Permalink
Merge pull request #3626 from fredliang44/main
Browse files Browse the repository at this point in the history
fix: removing `bearer` from auth header when using azure
  • Loading branch information
fredliang44 authored Dec 24, 2023
2 parents 771cc9e + c127db3 commit bd1e311
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 0 additions & 6 deletions app/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ export function auth(req: NextRequest, modelProvider: ModelProvider) {
if (!apiKey) {
const serverConfig = getServerSideConfig();

// const systemApiKey = serverConfig.isAzure
// ? serverConfig.azureApiKey
// : serverConfig.isGoogle
// ? serverConfig.googleApiKey
// : serverConfig.apiKey;

const systemApiKey =
modelProvider === ModelProvider.GeminiPro
? serverConfig.googleApiKey
Expand Down
4 changes: 3 additions & 1 deletion app/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const serverConfig = getServerSideConfig();
export async function requestOpenai(req: NextRequest) {
const controller = new AbortController();

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

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

0 comments on commit bd1e311

Please sign in to comment.