Merge pull request #3626 from fredliang44/main

fix: removing `bearer` from auth header when using azure
This commit is contained in:
Fred Liang 2023-12-25 05:26:55 +08:00 committed by GitHub
commit bd1e311674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -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

View File

@ -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(