From d640c93f7147c071bfdc1041424e3b7725cb742a Mon Sep 17 00:00:00 2001 From: Christo Todorov Date: Tue, 3 Sep 2024 14:49:42 +0200 Subject: [PATCH] fix: auto update issues --- apps/desktop/src-tauri/tauri.conf.json | 6 +++-- .../src/routes/api/check-updates/+server.ts | 24 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index 5df6110..9391fdf 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "Haptic", - "version": "0.1.2" + "version": "0.1.3" }, "tauri": { "allowlist": { @@ -56,7 +56,9 @@ }, "updater": { "active": true, - "endpoints": ["https://releases.myapp.com/{{target}}/{{arch}}/{{current_version}}"], + "endpoints": [ + "https://haptic.md/api/check-updates?target={{target}}&arch={{arch}}¤tVersion={{current_version}}" + ], "dialog": true, "windows": { "installMode": "passive" diff --git a/apps/homepage/src/routes/api/check-updates/+server.ts b/apps/homepage/src/routes/api/check-updates/+server.ts index 4952df5..da7037b 100644 --- a/apps/homepage/src/routes/api/check-updates/+server.ts +++ b/apps/homepage/src/routes/api/check-updates/+server.ts @@ -19,18 +19,16 @@ export const GET: RequestHandler = async ({ url }) => { const arch = url.searchParams.get('arch') as Arch | undefined; // Parse target and arch and validate with type - if (!target || !arch) { - if (!target || !arch || !currentVersion) { - return new Response( - JSON.stringify({ - error: 'Missing required parameters. Please provide target, arch, and currentVersion.' - }), - { - status: 400, - headers: { 'Content-Type': 'application/json' } - } - ); - } + if (!target || !arch || !currentVersion) { + return new Response( + JSON.stringify({ + error: 'Missing required parameters. Please provide target, arch, and currentVersion.' + }), + { + status: 400, + headers: { 'Content-Type': 'application/json' } + } + ); } // Validate target @@ -64,7 +62,7 @@ export const GET: RequestHandler = async ({ url }) => { const edgeConfig = (await configClient.getAll()) as { latest_version: string; notes?: string }; // Validate versions - if (currentVersion === edgeConfig.latest_version) { + if (currentVersion.replace('v', '') === edgeConfig.latest_version.replace('v', '')) { return new Response(null, { status: 204 }); }