mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	fixup: #1815 req.body will be broken in edge runtime
This commit is contained in:
		@@ -42,15 +42,19 @@ export async function requestOpenai(req: NextRequest) {
 | 
			
		||||
    },
 | 
			
		||||
    cache: "no-store",
 | 
			
		||||
    method: req.method,
 | 
			
		||||
    body: req.clone().body,
 | 
			
		||||
    body: req.body,
 | 
			
		||||
    signal: controller.signal,
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // #1815 try to refuse gpt4 request
 | 
			
		||||
  if (DISABLE_GPT4) {
 | 
			
		||||
  if (DISABLE_GPT4 && req.body) {
 | 
			
		||||
    try {
 | 
			
		||||
      const clonedBody = await req.clone().json();
 | 
			
		||||
      if ((clonedBody?.model ?? "").includes("gpt-4")) {
 | 
			
		||||
      const clonedBody = await req.text();
 | 
			
		||||
      fetchOptions.body = clonedBody;
 | 
			
		||||
 | 
			
		||||
      const jsonBody = JSON.parse(clonedBody);
 | 
			
		||||
 | 
			
		||||
      if ((jsonBody?.model ?? "").includes("gpt-4")) {
 | 
			
		||||
        return NextResponse.json(
 | 
			
		||||
          {
 | 
			
		||||
            error: true,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user