mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-13 04:33:42 +08:00
feat: #226
This commit is contained in:
@@ -67,9 +67,16 @@ export async function requestOpenai(req: NextRequest) {
|
||||
|
||||
let jsonBody;
|
||||
let clonedBody;
|
||||
if (req.method !== "GET" && req.method !== "HEAD") {
|
||||
const contentType = req.headers.get("Content-Type");
|
||||
if (
|
||||
req.method !== "GET" &&
|
||||
req.method !== "HEAD" &&
|
||||
contentType?.includes("json")
|
||||
) {
|
||||
clonedBody = await req.text();
|
||||
jsonBody = JSON.parse(clonedBody) as { model?: string };
|
||||
} else {
|
||||
clonedBody = req.body;
|
||||
}
|
||||
if (serverConfig.isAzure) {
|
||||
baseUrl = `${baseUrl}/${jsonBody?.model}`;
|
||||
@@ -77,7 +84,7 @@ export async function requestOpenai(req: NextRequest) {
|
||||
const fetchUrl = `${baseUrl}/${path}`;
|
||||
const fetchOptions: RequestInit = {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Type": contentType ?? "application/json",
|
||||
"Cache-Control": "no-store",
|
||||
[authHeaderName]: authValue,
|
||||
...(serverConfig.openaiOrgId && {
|
||||
|
||||
Reference in New Issue
Block a user