Files
supabase/apps/www/lib/rewrites.js
Jonathan Summers-MuirandClaude Opus 5.5 4da4e91a9b chore(www): make the launch week 16 rewrite readable (#54476)
Same paths as #54475, with the past launch weeks as named lists instead
of one regex.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 22:42:18 +08:00

130 lines
4.1 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*` },
]
// Launch Week 16 runs as its own app under /launch-week. The pages of past launch weeks stay on
// www, and keep the www security headers
const LAUNCH_WEEK_16 = 'https://launch-week-16.vercel.app/launch-week'
// these pages stay on www, with everything under them
const PAST_LAUNCH_WEEKS = ['6', '7', '8', '12', '13', '14', '15', 'x', 'tickets']
// this page stays on www, but not what is under it: the card editor of Launch Week 16 is at
// /launch-week/ticket/create/<step>
const PAST_LAUNCH_WEEK_PAGES = ['ticket']
const notPastLaunchWeek = [
...PAST_LAUNCH_WEEKS.map((path) => `${path}(?:/|$)`),
...PAST_LAUNCH_WEEK_PAGES.map((path) => `${path}$`),
].join('|')
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'),
// Launch Week 16. www removes the trailing slash and the app adds it, so the root targets
// '/launch-week/'
{
source: '/launch-week',
destination: `${LAUNCH_WEEK_16}/`,
},
{
source: `/launch-week/:path((?!${notPastLaunchWeek}).+)`,
destination: `${LAUNCH_WEEK_16}/:path`,
},
{
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