ChatGPTNextWeb / ChatGPT-Next-Web

A cross-platform ChatGPT/Gemini UI (Web / PWA / Linux / Win / MacOS). 一键拥有你自己的跨平台 ChatGPT/Gemini 应用。
https://app.nextchat.dev/
MIT License
72.56k stars 57.62k forks source link

接口如果返回的是201而不是200会导致意外情况 #4797

Open leadscloud opened 1 month ago

leadscloud commented 1 month ago

https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/da2e2372aa8490deee3fb50bd01dbdd9ca3f1dba/app/client/platforms/openai.ts#L216

if (
    !res.ok ||
    !res.headers
      .get("content-type")
      ?.startsWith(EventStreamContentType) ||
    res.status !== 200
  ) {

诸如nestjs中,post接口返回的默认是201,但以上判断是200,导致正常的stream内容直接以源内容格式显示,导致错误。

建议这个逻辑修改下。201也是res.ok

nextchat-manager[bot] commented 1 month ago

Please follow the issue template to update title and description of your issue.

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


Title: interface. If 201 is returned instead of 200, unexpected situations will occur.

https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/da2e2372aa8490deee3fb50bd01dbdd9ca3f1dba/app/client/platforms/openai.ts#L216

if (
    !res.ok ||
    !res.headers
      .get("content-type")
      ?.startsWith(EventStreamContentType) ||
    res.status !== 200
  ) {

For example, in nestjs, the default value returned by the post interface is 201, but the above judgment is 200, which causes the normal stream content to be displayed directly in the source content format, causing an error.

It is recommended that this logic be modified. 201 is also the res.ok

Dean-YZG commented 1 month ago

Thank you for your feedback, we will adopt the suggestion