fix: fix removing bearer header

This commit is contained in:
Fred Liang
2023-12-25 05:24:01 +08:00
parent 7ad1e246a0
commit f5ed1604aa
2 changed files with 3 additions and 7 deletions

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(