Resolve latest installer via serverless function#44
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
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 invercel.jsonwith a rewrite to/api/download. - Add
api/download.jsto 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 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}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces the hardcoded
/download/*redirects from #43 (which pinnedv0.1.0asset 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/:platformnow rewrites to/api/download?platform=:platform.mac→ aarch64.dmg,mac-intel→ x86_64.dmg,windows→.msi,linux→.AppImage;.sigsidecars excluded).s-maxage=600, stale-while-revalidate=86400) so real traffic almost never reaches GitHub's rate limit. HonoursGITHUB_TOKENif configured.Verification
v0.1.0release — each ofmac,mac-intel,windows,linuxresolves to exactly one asset.npm run build+npm run checkpass.Note
Vercel auto-deploys
/api/*as serverless functions even for a static Astro site, so no adapter change was needed. Optionally set aGITHUB_TOKENenv var in Vercel for a higher API rate limit.🤖 Generated with Claude Code