ChatGPTNextWeb / ChatGPT-Next-Web

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

[Bug] 配置阿里的通义千问报错,显示 cors限制 #4980

Closed kulame closed 2 months ago

kulame commented 2 months ago

Bug Description

Access to fetch at 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

应该如何处理?

Steps to Reproduce

1 配置ALIBABA_API_KEY和ALIBABA_URL

Expected Behavior

配置通义千问的api结果报错,提示cors错误。

Screenshots

No response

Deployment Method

Desktop OS

No response

Desktop Browser

No response

Desktop Browser Version

No response

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

Issues-translate-bot commented 2 months ago

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


Title: [Bug] Configure Alibaba's Tongyi Qianwen to report errors and display cors restrictions

RubuJam commented 2 months ago

通义千问目前不支持跨域请求,当下只有修改源代码中的地址才行

Tongyi Qianwen does not currently support cross-domain requests. Currently, the only way to do this is to modify the address in the source code.

lloydzhou commented 2 months ago

直接填写官方的地址,在浏览器发请求会触发跨域错误。 可以使用 /api/alibaba 这个内置的地址走next server做转发,或者使用自己部署的转发地址。 但是还是建议通过ALIBABA_API_KEY以及ALIBABA_URL自己部署服务使用,以保护自己的key不外泄。

Issues-translate-bot commented 2 months ago

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


Directly filling in the official address and making a request in the browser will trigger a cross-domain error. You can use the built-in address /api/alibaba to go to the next server for forwarding, or use the forwarding address deployed by yourself. However, it is still recommended to deploy services yourself through ALIBABA_API_KEY and ALIBABA_URL to protect your own keys from being leaked.