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]