Skip to content

Resolve latest installer via serverless function#44

Merged
BunsDev merged 1 commit into
mainfrom
feat/download-serverless-resolver
Jul 14, 2026
Merged

Resolve latest installer via serverless function#44
BunsDev merged 1 commit into
mainfrom
feat/download-serverless-resolver

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 14, 2026

Copy link
Copy Markdown
Member

What

Replaces the hardcoded /download/* redirects from #43 (which pinned v0.1.0 asset filenames and needed a manual bump every release) with a Vercel serverless function, api/download.js.

It queries the GitHub API for the latest release at request time, picks the correct installer asset per platform, and 302s straight to the file — still a real download, never the Releases listing page, and now zero maintenance per release.

How it works

  • vercel.json: /download/:platform now rewrites to /api/download?platform=:platform.
  • The function matches one asset per platform (mac → aarch64 .dmg, mac-intel → x86_64 .dmg, windows.msi, linux.AppImage; .sig sidecars excluded).
  • The 302 is CDN-cached (s-maxage=600, stale-while-revalidate=86400) so real traffic almost never reaches GitHub's rate limit. Honours GITHUB_TOKEN if configured.
  • Any failure degrades gracefully to the releases page.

Verification

  • Matchers tested against the live v0.1.0 release — each of mac, mac-intel, windows, linux resolves to exactly one asset.
  • npm run build + npm run check pass.

Note

Vercel auto-deploys /api/* as serverless functions even for a static Astro site, so no adapter change was needed. Optionally set a GITHUB_TOKEN env var in Vercel for a higher API rate limit.

🤖 Generated with Claude Code

Replace the hardcoded /download/* redirects (which pinned v0.1.0 asset
filenames and needed a manual bump every release) with a Vercel
serverless function, api/download.js. It queries the GitHub API for the
latest release at request time, picks the correct installer asset per
platform, and 302s straight to the file — still a real download, never
the Releases listing page, and now zero maintenance per release.

- vercel.json: /download/:platform now rewrites to /api/download.
- The 302 is CDN-cached (s-maxage=600, stale-while-revalidate) so real
  traffic almost never hits GitHub's 60/hr unauthenticated rate limit;
  honours GITHUB_TOKEN if configured.
- Any failure (rate limit, network, missing asset, unknown platform)
  degrades gracefully to the releases page.

Matchers verified against the live v0.1.0 release: each of mac,
mac-intel, windows, linux resolves to exactly one asset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 14, 2026 18:34
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
coven Ready Ready Preview Jul 14, 2026 6:34pm
coven-landing Ready Ready Preview Jul 14, 2026 6:34pm

@BunsDev
BunsDev merged commit b2edcd5 into main Jul 14, 2026
3 checks passed
@BunsDev
BunsDev deleted the feat/download-serverless-resolver branch July 14, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces hardcoded /download/* Vercel redirects with a /download/:platform rewrite to a Vercel serverless function that resolves the latest GitHub Release installer asset at request time and 302-redirects directly to the file, removing per-release maintenance.

Changes:

  • Replace static /download/* redirects in vercel.json with a rewrite to /api/download.
  • Add api/download.js to query GitHub’s “latest release”, select the platform installer asset, and redirect with CDN caching (or fall back to the Releases page).
  • Update in-repo comments to reflect the new download resolution approach.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
vercel.json Removes pinned release-asset redirects and rewrites /download/:platform to the new serverless resolver.
src/scripts/main.js Updates download-route documentation comments for the CTA logic.
src/components/DownloadCTA.astro Updates component documentation comments to match the serverless download resolver design.
api/download.js Implements the serverless function that resolves latest release assets and redirects with CDN caching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/download.js
Comment on lines +54 to +56
const asset = assets.find((a) => a && typeof a.name === 'string' && !a.name.endsWith('.sig') && match(a.name));

if (!asset || !asset.browser_download_url) throw new Error(`no asset for ${platform}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants