diff --git a/packages/console/app/src/routes/download/[channel]/[platform].ts b/packages/console/app/src/routes/download/[channel]/[platform].ts index da5b0733bc..a49623c786 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) {