fix: agent download URL — return absolute api.hotelsync.ru URL

Relative /agent-updates/ path was resolving to app.hotelsync.ru
(frontend) instead of api.hotelsync.ru, returning HTML instead of .exe

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-27 17:50:11 +03:00
parent 69f0a051a7
commit 20815ae21f

View File

@@ -13,7 +13,8 @@ const agentRelease: FastifyPluginAsync = async (fastify) => {
if (!versionMatch) return reply.code(404).send({ error: 'latest.yml not found or invalid' }) if (!versionMatch) return reply.code(404).send({ error: 'latest.yml not found or invalid' })
const version = versionMatch[1].trim() const version = versionMatch[1].trim()
const fileName = pathMatch?.[1].trim() ?? `HotelSync Agent Setup ${version}.exe` const fileName = pathMatch?.[1].trim() ?? `HotelSync Agent Setup ${version}.exe`
return { version, fileName, downloadUrl: `/agent-updates/${encodeURIComponent(fileName)}` } const host = process.env.API_PUBLIC_URL ?? 'https://api.hotelsync.ru'
return { version, fileName, downloadUrl: `${host}/agent-updates/${encodeURIComponent(fileName)}` }
} catch { } catch {
return reply.code(404).send({ error: 'No release available' }) return reply.code(404).send({ error: 'No release available' })
} }