Commit 70d8cc0
authored
feat: redirect vite.plus vanity domain to installer scripts (#30)
## What
The `vite.plus` apex domain now points at this Worker. This adds a
host-based redirect so the short domain works as an installer entry
point:
| Request | Result |
| --- | --- |
| `https://vite.plus` | 302 -> `https://viteplus.dev/install.sh` |
| `https://vite.plus/ps1` | 302 -> `https://viteplus.dev/install.ps1` |
So `curl https://vite.plus | sh` and `irm https://vite.plus/ps1 | iex`
both work.
## How
New middleware `middleware/02.redirect-vite-plus.ts`, mirroring the
existing `01.redirect-to-custom-domain.ts` pattern with an extracted,
unit-tested `buildViteplusRedirect()` helper.
- Only the `vite.plus` apex host is matched. The canonical
`setup.viteplus.dev` host, the legacy `vp-setup.void.app` host, and
`localhost` (dev) fall through untouched, so the download page and
existing legacy redirect keep working.
- `www.vite.plus` is intentionally not matched (only the apex was
requested).
- Any path other than `/ps1` defaults to `install.sh`; a trailing slash
on `/ps1` is tolerated.
## Tests
Adds `tests/redirect-vite-plus.test.ts` (9 cases): both redirect rules,
trailing slash, arbitrary paths, query strings, and the
null/fall-through cases for other hosts and a missing host header. `vp
check` and `vp test` (31 tests) pass.
## Note for deploy
For these redirects to fire, `vite.plus` must be attached as a custom
domain/route on the deployed Worker, not just pointed via DNS. Once
requests reach the Worker with `Host: vite.plus`, the redirect applies.1 parent 61b472c commit 70d8cc0
2 files changed
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
0 commit comments