Merge branch 'ChatGPTNextWeb:main' into main

This commit is contained in:
money32wang 2023-12-25 17:20:06 +08:00 committed by GitHub
commit 6178eaaee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,10 +9,21 @@ const serverConfig = getServerSideConfig();
export async function requestOpenai(req: NextRequest) { export async function requestOpenai(req: NextRequest) {
const controller = new AbortController(); const controller = new AbortController();
const authValue = var authValue,
req.headers.get("Authorization")?.trim().replaceAll("Bearer ", "").trim() ?? authHeaderName = "";
""; if (serverConfig.isAzure) {
const authHeaderName = serverConfig.isAzure ? "api-key" : "Authorization"; authValue =
req.headers
.get("Authorization")
?.trim()
.replaceAll("Bearer ", "")
.trim() ?? "";
authHeaderName = "api-key";
} else {
authValue = req.headers.get("Authorization") ?? "";
authHeaderName = "Authorization";
}
let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll( let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(
"/api/openai/", "/api/openai/",