fix(website): fetch release version at runtime with asset validation

Move release version resolution from build-time (vite.config.ts) to
runtime (server function on Cloudflare Workers). The server function
fetches GitHub releases, filters out prereleases/drafts, and only
returns a version that has all required assets (Mac DMG, Linux AppImage,
Windows exe). Uses Cloudflare's cf.cacheEverything with a 60s TTL to
avoid hitting GitHub on every request.

This fixes a race condition where the website would deploy and show
download links for a new release before the desktop build assets were
actually uploaded, resulting in 404s for users.
This commit is contained in:
Mohamed Boudra
2026-04-03 20:41:26 +07:00
parent 49402b854f
commit 1ae2f9280e
6 changed files with 152 additions and 76 deletions
+1 -20
View File
@@ -28,27 +28,8 @@ const sitemapPages = [
path: routePath,
}));
async function fetchLatestReleaseVersion(): Promise<string | undefined> {
try {
const res = await fetch(
"https://api.github.com/repos/getpaseo/paseo/releases/latest",
{ headers: { Accept: "application/vnd.github+json" }, signal: AbortSignal.timeout(5000) },
);
if (!res.ok) return undefined;
const data = (await res.json()) as { tag_name: string };
return data.tag_name.replace(/^v/, "");
} catch {
return undefined;
}
}
export default defineConfig(async (): Promise<UserConfig> => {
const latestVersion = await fetchLatestReleaseVersion();
export default defineConfig((): UserConfig => {
return {
define: {
...(latestVersion && { __DESKTOP_VERSION__: JSON.stringify(latestVersion) }),
},
server: {
port: 8082,
fs: {