mirror of
https://github.com/supabase/supabase.git
synced 2026-12-05 16:09:06 +00:00
## Problem
We're building the site for Supabase Builder Day: 14 cities, one day, 10
December. It's its own Next.js app on Vercel (on the Supabase team) and
right now it only lives at `builderday.vercel.app`.
We want it at **supabase.com/builderday** so the links on the Luma pages
and in our emails point at a Supabase address, and so builders can sign
in with the Supabase account they already have instead of making a new
one.
## Solution
- `zoneRewrites('/builderday', ...)` in `apps/www/lib/rewrites.js`, the
same way `/library` and `/design-system` are served, so RSC prefetches
go through too.
- The app runs with `basePath: '/builderday'`, so its `/_next` assets
and `/api` routes stay under the prefix and don't collide with www's.
- `/builder-day` redirects to `/builderday`.
- A test next to the InstantDB one in `next.config.test.ts`.
**Depends on:** supabase/Builderday#5, which adds the base path on our
side. Until that's merged, `/builderday` returns 404.
## Review instructions
1. `cd apps/www && pnpm vitest run next.config.test.ts`
2. Once supabase/Builderday#5 is live, open `/builderday` on the www
preview: the Builder Day page loads, with no 404s for `/_next` or `/api`
in the network tab.
3. `/builder-day` redirects to `/builderday`.
4. `/dashboard`, `/docs` and `/library` still work.
## Checklist
- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
107 lines
3.2 KiB
JavaScript
107 lines
3.2 KiB
JavaScript
const LIBRARY_URL = process.env.NEXT_PUBLIC_LIBRARY_URL ?? process.env.NEXT_PUBLIC_UI_LIBRARY_URL
|
|
|
|
const zoneRewrites = (basePath, url) => [
|
|
// vercel keeps the segment prefetch header on .segments paths. the zone then adds the suffix again
|
|
{
|
|
source: `${basePath}/:path(.*)\\.segments/:segment(.*)\\.segment\\.rsc`,
|
|
destination: `${url}/:path`,
|
|
},
|
|
{ source: `${basePath}\\.segments/:segment(.*)\\.segment\\.rsc`, destination: `${url}` },
|
|
// a zone serves its root as index.rsc
|
|
{ source: `${basePath}\\.rsc`, destination: `${url}` },
|
|
{ source: basePath, destination: `${url}` },
|
|
{ source: `${basePath}/:path*`, destination: `${url}/:path*` },
|
|
]
|
|
|
|
const rewrites = [
|
|
{
|
|
source: '/:path*',
|
|
destination: `/:path*`,
|
|
},
|
|
{
|
|
source: '/dashboard',
|
|
destination: `${process.env.NEXT_PUBLIC_STUDIO_URL}`,
|
|
},
|
|
{
|
|
source: '/dashboard/:path*',
|
|
destination: `${process.env.NEXT_PUBLIC_STUDIO_URL}/:path*`,
|
|
},
|
|
...(process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'
|
|
? [
|
|
{
|
|
source: '/docs/',
|
|
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}`,
|
|
},
|
|
...zoneRewrites('/docs', process.env.NEXT_PUBLIC_DOCS_URL),
|
|
]
|
|
: []),
|
|
...zoneRewrites('/library', LIBRARY_URL),
|
|
...zoneRewrites('/design-system', process.env.NEXT_PUBLIC_DESIGN_SYSTEM_URL),
|
|
{
|
|
source: '/kb',
|
|
destination: `${process.env.NEXT_PUBLIC_KB_URL}`,
|
|
},
|
|
{
|
|
source: '/kb/:path*',
|
|
destination: `${process.env.NEXT_PUBLIC_KB_URL}/:path*`,
|
|
},
|
|
{
|
|
source: '/evals',
|
|
destination: 'https://supabase-evals.vercel.app',
|
|
},
|
|
{
|
|
source: '/evals/:path*',
|
|
destination: 'https://supabase-evals.vercel.app/:path*',
|
|
},
|
|
{
|
|
source: '/migrate/instantdb',
|
|
destination: 'https://instantdb-to-supabase.vercel.app/migrate/instantdb',
|
|
},
|
|
{
|
|
source: '/migrate/instantdb/:path*',
|
|
destination: 'https://instantdb-to-supabase.vercel.app/migrate/instantdb/:path*',
|
|
},
|
|
// Builder Day: the event site runs as its own Next.js app with basePath '/builderday'
|
|
...zoneRewrites('/builderday', 'https://builderday.vercel.app/builderday'),
|
|
|
|
{
|
|
source: '/new-docs',
|
|
destination: `${process.env.NEXT_PUBLIC_REFERENCE_DOCS_URL}`,
|
|
},
|
|
{
|
|
// redirect /docs/
|
|
// trailing slash caused by docusaurus issue with multizone
|
|
source: '/new-docs/',
|
|
destination: `${process.env.NEXT_PUBLIC_REFERENCE_DOCS_URL}`,
|
|
},
|
|
{
|
|
source: '/new-docs/:path*',
|
|
destination: `${process.env.NEXT_PUBLIC_REFERENCE_DOCS_URL}/:path*`,
|
|
},
|
|
// misc rewrites
|
|
{
|
|
source: '/humans.txt',
|
|
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}/humans.txt`,
|
|
},
|
|
{
|
|
source: '/lawyers.txt',
|
|
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}/lawyers.txt`,
|
|
},
|
|
{
|
|
source: '/.well-known/security.txt',
|
|
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}/.well-known/security.txt`,
|
|
},
|
|
{
|
|
// legacy AI Catalog path; /.well-known/ard.json is the canonical source
|
|
source: '/.well-known/ai-catalog.json',
|
|
destination: '/.well-known/ard.json',
|
|
},
|
|
{
|
|
source: '/openapi.json',
|
|
destination: 'https://api.supabase.com/api/v1-json',
|
|
},
|
|
{ source: '/feed.xml', destination: `/rss.xml` },
|
|
]
|
|
|
|
module.exports = rewrites
|