Files
supabase/.misspell-fixer.ignore
Mert YEREKAPAN fe8e912993 refactor(www): split redirects into static and dynamic files and add redirect checks (#54194)
## Problem

`apps/www/lib/redirects.js` was a single file with static and dynamic
rules mixed together, and the redirects had no automated checks. `/docs`
redirects already moved to `apps/docs/lib/redirects/`, so www was the
odd one out.

## Solution

I applied the docs layout to www without changing how redirects are
served:

- `apps/www/lib/redirects/static-redirects.json`: 220 one-to-one
entries, including fixed redirects to external `https://` URLs.
- `apps/www/lib/redirects/dynamic-redirects.js`: 14 entries with params,
splats, regex, escapes, or `has`.
- `apps/www/lib/redirects/index.js`: combines both (static first) for
`next.config.mjs` and `scripts/generateMdContent.mjs`.
- `apps/www/lib/redirects/redirects.test.ts`: checks for loops, chains,
duplicate sources, invalid sources and destinations (anchors, missing
`/` or `https://`), dynamic entries in the static file, and internal
destinations that do not exist.
- README for the folder, plus updates to `apps/www/README.md`,
`DEVELOPERS.md`, `CODEOWNERS`, and the `www-tests` path filter and
sparse checkout.

Bulk redirects are not part of this PR: www has 234 redirects, well
under the route limit, so they stay in `next.config.mjs`.

### Missing-destination check

Internal destinations are checked against the same sources the site
serves from:

- `app/` and `pages/` routes, and `public/` files.
- Blog, customer, event, and alternative slugs, derived the way
`lib/posts.tsx` derives them. Events with `disable_page_build` do not
count.
- Feature and `/go` page slugs.
- `.md` destinations must be a page that `generateMdContent.mjs`
publishes. An existing HTML page is not enough.
- `/docs/guides` destinations, against the docs content and guide
routes.

Other zones and build-generated files are not checked. A destination
with params is probed with one sample value, so value-specific loops or
chains are not caught. The README lists these limits.

### Behavior notes

- The rule set matches `master`, with one exception:
`/blog/2021/07/30/1-the-supabase-hackathon` now points at the canonical
slug `/blog/1-the-supabase-hackathon`. The old destination
`/blog/the-supabase-hackathon` also resolves today, because the blog
route matches posts by filename suffix. The check requires canonical
slugs.
- First-match results on `supabase.com` are identical on 241 probe
paths.
- Static entries now precede dynamic ones. On the `supabase.design`
host, 25 static sources that used to sit after its catch-all rule now
come before it. Those paths now take two hops to reach the design system
instead of one.
- Comments on static entries were dropped, because JSON has no comments.

## To test

1. Open the www preview and visit `/about`. It redirects to `/company`.
2. Visit `/buildersday`. It redirects to `/builderday`.
3. Visit `/sign-in`. It redirects to the dashboard sign-in page.
4. Visit `/blog/2021/07/30/1-the-supabase-hackathon`. It lands on the
hackathon post.

## Linear

- fixes GROWTH-1571
2026-11-30 15:52:59 +00:00

4 lines
80 B
Plaintext

^./i18n
^./packages/api-types
^./apps/www/lib/redirects/
^./apps/studio/public/*