Browse Source

api: set Content-Type to json

This avoids issues in browsers like WeChat where the encoding is
incorrect and the summary feature does not work if it contains
zh-CN characters.
Jun Wu 1 year ago
parent
commit
83cea2adb8
1 changed files with 4 additions and 2 deletions
  1. 4 2
      app/api/openai/route.ts

+ 4 - 2
app/api/openai/route.ts

@@ -3,8 +3,10 @@ import { requestOpenai } from "../common";
 
 async function makeRequest(req: NextRequest) {
   try {
-    const res = await requestOpenai(req);
-    return new Response(res.body);
+    const api = await requestOpenai(req);
+    const res = new NextResponse(api.body);
+    res.headers.set('Content-Type', 'application/json');
+    return res;
   } catch (e) {
     console.error("[OpenAI] ", req.body, e);
     return NextResponse.json(