Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 3 tasks
kulame opened this issue Jul 12, 2024 · 4 comments
Closed
1 of 3 tasks

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

kulame opened this issue Jul 12, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@kulame
Copy link

kulame commented Jul 12, 2024

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

  • Docker
  • Vercel
  • Server

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

@kulame kulame added the bug Something isn't working label Jul 12, 2024
@Issues-translate-bot
Copy link

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

@lloydzhou lloydzhou self-assigned this Jul 12, 2024
@RubuJam
Copy link
Contributor

RubuJam commented Jul 12, 2024

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

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
Copy link
Collaborator

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

@Issues-translate-bot
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants