From 4da4e91a9b84d972d7cb2189859172cf720ae8a3 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Wed, 2 Dec 2026 22:42:18 +0800 Subject: [PATCH] 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 --- apps/www/lib/rewrites.js | 25 ++++++++++++++++++------- apps/www/lib/security-headers.test.ts | 3 +++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/apps/www/lib/rewrites.js b/apps/www/lib/rewrites.js index 8fb8aa80060..8a4d470a06f 100644 --- a/apps/www/lib/rewrites.js +++ b/apps/www/lib/rewrites.js @@ -13,6 +13,19 @@ const zoneRewrites = (basePath, 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/ +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*', @@ -63,17 +76,15 @@ const rewrites = [ }, // 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: the card app runs as its own app with base '/launch-week/' - // www removes the trailing slash and the app adds it, so the root targets '/launch-week/' + // Launch Week 16. www removes the trailing slash and the app adds it, so the root targets + // '/launch-week/' { source: '/launch-week', - destination: 'https://launch-week-16.vercel.app/launch-week/', + destination: `${LAUNCH_WEEK_16}/`, }, - // past launch weeks stay on www and keep the www security headers - // only the exact /ticket path is the lw15 page. the lw16 editor uses /ticket/create { - source: '/launch-week/:path((?!(?:6|7|8|12|13|14|15|x|tickets)(?:/|$)|ticket$).+)', - destination: 'https://launch-week-16.vercel.app/launch-week/:path', + source: `/launch-week/:path((?!${notPastLaunchWeek}).+)`, + destination: `${LAUNCH_WEEK_16}/:path`, }, { diff --git a/apps/www/lib/security-headers.test.ts b/apps/www/lib/security-headers.test.ts index 1f34ee98d72..2f1f2278831 100644 --- a/apps/www/lib/security-headers.test.ts +++ b/apps/www/lib/security-headers.test.ts @@ -257,6 +257,7 @@ describe('getSecurityHeaderRules', () => { '/launch-week/t/someone', '/launch-week/ticket/create/select-material', '/launch-week/16', + '/launch-week/ticket/create/decorate', ])('does not apply to the proxied path %s', (path) => { expect(headerMatches(wwwRule.source, path)).toBe(false) }) @@ -295,7 +296,9 @@ describe('getSecurityHeaderRules', () => { '/launch-week/15', '/launch-week/16', '/launch-week/ticket', + '/launch-week/ticket/create/decorate', '/launch-week/tickets/someone', + '/launch-week/tickets', '/launch-week/sign-in', '/launch-week/assets/index.js', '/migrate',