pot-desktop
pot-desktop copied to clipboard
[BUG]: 设置OpenAI的请求地址里如果域名后面带端口的话就会一直报错
Description
设置OpenAI的请求地址里域名后面如果带自定义的端口号的话就会一直报错
Network Error: error sending request for url (https://xxxx.com:3030/v1/chat/completions): error trying to connect: 接收到的消息异常,或格式不正确。 (os error -2146893018): error sending request for url (https://xxxx.com:3030/v1/chat/completions): error trying to connect: 接收到的消息异常,或格式不正确。 (os error -2146893018): error trying to connect: 接收到的消息异常,或格式不正确。 (os error -2146893018): 接收到的消息异常,或格式不正确。 (os error -2146893018)
看代码.\src\services\translate\openai现在的请求方式是:
let res = await fetch(apiUrl.href, {
method: 'POST',
headers: headers,
body: Body.json(body),
});
相同的地址使用下面这种方式去请求的话就不会报错了
const res = await window.fetch(apiUrl.href, {
method: 'POST',
headers: headers,
body: JSON.stringify(body)
});
const result = await res.json();
感觉是tauri的网络库版本太老了,需要升级了
Reproduction
添加内置服务OpenAI,然后设置请求地址,保存时报错
Platform
Windows
System Version
Win11 24H2 26100.2605
Window System (Linux Only)
None
Software Version
3.0.6
Log File
No response
Additional Information
No response
前端 fetch 会受到浏览器cros的影响