silveur
silveur

Reputation: 167

Electron autoUpdater Error: Update check failed / invalid JSON response

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?

Upvotes: 1

Views: 861

Answers (1)

silveur
silveur

Reputation: 167

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`

Upvotes: 2

Related Questions