fix: return bearer header when using openai

This commit is contained in:
Fred Liang 2023-12-25 09:56:51 +08:00
parent bd1e311674
commit 19137b79bc
No known key found for this signature in database
GPG Key ID: 4DABDA85EF70EC71

View File

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