英文:
Electron autoUpdater Error: Update check failed / invalid JSON response
问题
当尝试使用 Electron 的 autoUpdate 模块时,它从我的 Vercel 应用中获取更新,例如:
https://backoffice-electron-updater.vercel.app/update/darwin/1.2.366
响应似乎是有效的:
{"name":"v1.2.367","notes":"","pub_date":"2023-03-09T16:01:51Z","url":"backoffice-electron-updater-1auzox7wu-common-ground.vercel.app/download/darwin?update=true"}
Electron 应用接收到此更新的 JSON 响应后,然后抛出错误:
[Error: Update check failed. The server sent an invalid JSON response. Try again later.] {
code: 6,
domain: 'SQRLUpdaterErrorDomain'
}
我不确定为什么这个响应是无效的,JSON 响应中是否缺少某个键?
- 我在 M1 13.0 上进行测试
- Electron 版本是 23.1.1
- 应用发布位于私有 GitHub 存储库后面。
- 应用发布已成功由苹果进行公证
- Hazel 服务器已配置了名为 TOKEN 的环境变量(我的 GitHub 个人令牌)。
- 传递给 setFeedURL() 的 url 参数是 https://backoffice-electron-updater.vercel.app/update/darwin/1.2.366
英文:
When trying the autoUpdate module from Electron, it fetches the update from my Vercel app such as:
https://backoffice-electron-updater.vercel.app/update/darwin/1.2.366
The response seems valid:
{"name":"v1.2.367","notes":"","pub_date":"2023-03-09T16:01:51Z","url":"backoffice-electron-updater-1auzox7wu-common-ground.vercel.app/download/darwin?update=true"}
The Electron app receiving this update JSON response is then throwing the error:
[Error: Update check failed. The server sent an invalid JSON response. Try again later.] {
code: 6,
domain: 'SQRLUpdaterErrorDomain'
}
I'm unsure why this response is invalid, is there a key missing in the JSON response?
- I am testing on M1 13.0
- Electron version is 23.1.1
- App releases are behind a private github repo.
- App releases are notarized by Apple successfully
- Hazel server is configured with environment variable TOKEN (my github personal token).
- The url argument passed to setFeedURL() is https://backoffice-electron-updater.vercel.app/update/darwin/1.2.366
答案1
得分: 2
经过长时间的调试,我发现 Electro 自动更新模块不会接受从非 HTTPS URL 获取更新包。
Vercel 的 URL 环境变量没有包含 HTTPS。
修改 Hazel 源代码以添加 HTTPS 修复了这个问题:
https://github.com/vercel/hazel/blob/master/lib/routes.js#L167
如果你在使用 GitHub 私有仓库,只需将其更改为:
? `https://${url}/download/${platformName}?update=true`
英文:
After long hours of debugging I found out that the Electro auto updater module would not accept fetching update packages from non-https URLs.
The URL env variable from Vercel is without https.
Modifying the Hazel source code to add https fixed it:
https://github.com/vercel/hazel/blob/master/lib/routes.js#L167
If you are using a Github private repo, simply change it to:
? `https://${url}/download/${platformName}?update=true`
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论