From fee476bb90043a1012abda156dd9af9e5c71b19d Mon Sep 17 00:00:00 2001 From: "opencode-agent[bot]" <219766164+opencode-agent[bot]@users.noreply.github.com> Date: Sat, 19 Sep 2026 14:31:47 +0000 Subject: [PATCH] refactor(console): redirect desktop downloads (#49984) Co-authored-by: thdxr <826656+thdxr@users.noreply.github.com> --- .../routes/download/[channel]/[platform].ts | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/packages/console/app/src/routes/download/[channel]/[platform].ts b/packages/console/app/src/routes/download/[channel]/[platform].ts index da5b0733bc4..a49623c7864 100644 --- a/packages/console/app/src/routes/download/[channel]/[platform].ts +++ b/packages/console/app/src/routes/download/[channel]/[platform].ts @@ -1,5 +1,4 @@ import type { APIEvent } from "@solidjs/start" -import { waitUntil } from "@opencode-ai/console-resource" import type { DownloadPlatform } from "../types" const prodAssetNames: Record = { @@ -20,13 +19,6 @@ const betaAssetNames: Record = { "linux-x64-rpm": "opencode-desktop-linux-x86_64.rpm", } satisfies Record -// Doing this on the server lets us preserve the original name for platforms we don't care to rename for -const downloadNames: Record = { - "darwin-aarch64-dmg": "OpenCode Desktop.dmg", - "darwin-x64-dmg": "OpenCode Desktop.dmg", - "windows-x64-nsis": "OpenCode Desktop Installer.exe", -} satisfies { [K in DownloadPlatform]?: string } - export async function GET({ params: { platform, channel } }: APIEvent) { const assetName = channel === "stable" ? prodAssetNames[platform] : betaAssetNames[platform] if (!assetName) return new Response(null, { status: 404 }) @@ -37,30 +29,7 @@ export async function GET({ params: { platform, channel } }: APIEvent) { if (!release.ok) return new Response(null, { status: release.status }) const location = getAssetUrl(await release.json(), assetName) if (!location) return new Response(null, { status: 502 }) - - const key = new Request(location) - const cache = (caches as CacheStorage & { default: Cache }).default - const cached = await cache.match(key) - if (cached) return download(cached, platform, "HIT") - - const resp = await fetch(location) - if (!resp.ok) return resp - - const headers = new Headers(resp.headers) - headers.set("cache-control", "public, max-age=31536000, immutable") - headers.delete("set-cookie") - const result = new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers }) - waitUntil(cache.put(key, result.clone())) - return download(result, platform, "MISS") -} - -function download(resp: Response, platform: string, cache: "HIT" | "MISS") { - const downloadName = downloadNames[platform] - const headers = new Headers(resp.headers) - if (downloadName) headers.set("content-disposition", `attachment; filename="${downloadName}"`) - headers.set("x-opencode-cache", cache) - - return new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers }) + return Response.redirect(location, 302) } function getAssetUrl(input: unknown, assetName: string) {