From 589582a839b24a16dc68a1c2e92e14b83b5b237e Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Sat, 24 Jan 2026 14:23:43 -0500 Subject: [PATCH] fix(redirects): use Cloudflare Worker for install script redirects Replace _redirects file with a Cloudflare Worker to handle redirects for /install.ps1 and /install.sh to the GitHub releases. This provides more control and reliability for redirect handling. Closes CodingWithCalvin/dtvem.cli#200 --- website/public/_redirects | 2 -- website/worker.ts | 19 +++++++++++++++++++ website/wrangler.toml | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) delete mode 100644 website/public/_redirects create mode 100644 website/worker.ts diff --git a/website/public/_redirects b/website/public/_redirects deleted file mode 100644 index 68347fa..0000000 --- a/website/public/_redirects +++ /dev/null @@ -1,2 +0,0 @@ -/install.ps1 https://github.com/CodingWithCalvin/dtvem.cli/releases/latest/download/install.ps1 302 -/install.sh https://github.com/CodingWithCalvin/dtvem.cli/releases/latest/download/install.sh 302 diff --git a/website/worker.ts b/website/worker.ts new file mode 100644 index 0000000..be6e377 --- /dev/null +++ b/website/worker.ts @@ -0,0 +1,19 @@ +const REDIRECTS: Record = { + '/install.ps1': 'https://github.com/CodingWithCalvin/dtvem.cli/releases/latest/download/install.ps1', + '/install.sh': 'https://github.com/CodingWithCalvin/dtvem.cli/releases/latest/download/install.sh', +}; + +export default { + async fetch(request: Request, env: { ASSETS: { fetch: typeof fetch } }): Promise { + const url = new URL(request.url); + + // Check for redirects + const redirectTarget = REDIRECTS[url.pathname]; + if (redirectTarget) { + return Response.redirect(redirectTarget, 302); + } + + // Fall through to static assets + return env.ASSETS.fetch(request); + }, +}; diff --git a/website/wrangler.toml b/website/wrangler.toml index 831028e..9251935 100644 --- a/website/wrangler.toml +++ b/website/wrangler.toml @@ -1,4 +1,5 @@ name = "dtvem-io" +main = "./worker.ts" compatibility_date = "2024-12-01" [assets]