当浏览器直接请求 API 出现 "Failed to fetch" 错误时,说明遇到了 CORS 跨域限制。
解决方案:填写一个 CORS 代理地址,请求会通过代理转发。代理地址前缀 + 实际 API 地址 = 最终请求地址。
示例:若代理为 https://cors-proxy.example.com/?url=,请求 https://api.openai.com/v1/chat/completions 时,实际发送到 https://cors-proxy.example.com/?url=https://api.openai.com/v1/chat/completions
https://cors-proxy.example.com/?url=
https://api.openai.com/v1/chat/completions
https://cors-proxy.example.com/?url=https://api.openai.com/v1/chat/completions
自建代理推荐:部署 cors-anywhere 或使用 Cloudflare Workers 搭建。