Deeptrain-Community / chatnio

🚀 Next Generation AI One-Stop Internationalization Solution. 🚀 下一代 AI 一站式 B/C 端解决方案,支持 OpenAI,Midjourney,Claude,讯飞星火,Stable Diffusion,DALL·E,ChatGLM,通义千问,腾讯混元,360 智脑,百川 AI,火山方舟,新必应,Gemini,Moonshot 等模型,支持对话分享,自定义预设,云端同步,模型市场,支持弹性计费和订阅计划模式,支持图片解析,支持联网搜索,支持模型缓存,丰富美观的后台管理与仪表盘数据统计。
https://chatnio.com
Apache License 2.0
2.71k stars 447 forks source link

APP:// CORS问题 #158

Closed conql closed 1 month ago

conql commented 3 months ago

使用OpenAI Node API库请求时会导致CORS错误。 image

X-Stainless-.......的请求头是由OpenAI的官方库引入的 image

zmh-program commented 3 months ago

自定义请求头一般是不会影响的,目测可能是app:// scheme的问题

conql commented 3 months ago

自定义请求头一般是不会影响的,目测可能是app:// scheme的问题

又测试了一下,好像不是

image

复现代码:

await fetch("https://api.chatnio.net/v1/models",{
    method:"GET",
    headers:{
    }
}).then(t=>t.json()).then(t=>console.log("No header",t))

await fetch("https://api.chatnio.net/v1/models",{
    method:"GET",
    headers:{
        "X-Stainless-Lang":"js"
    }
}).then(t=>t.json()).then(t=>console.log("Has header",t))
zmh-program commented 3 months ago

这是你的app的问题吧

conql commented 3 months ago

image

conql commented 3 months ago

https://chatnio.net 上跑也一样

zmh-program commented 3 months ago

浏览器?

conql commented 3 months ago

是的

zmh-program commented 3 months ago

OK 复现到了 等我处理完 #77 来处理

zmh-program commented 3 months ago

商业版和chatnio官网已经修复,功能将由 @Sh1n3zZ 下放开源版。