From 015ec111bd67af8200a23d65885ab3120f186767 Mon Sep 17 00:00:00 2001 From: chenhang Date: Wed, 17 Jun 2026 11:30:57 +0800 Subject: [PATCH] fix(pwa): rename serwist route from [[...slug]] to [path] to match Serwist's hardcoded param MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Serwist createSerwistRoute factory returns a GET handler with `params: Promise<{ path: string }>` hardcoded. Next.js infers the param shape from the directory name — so the directory MUST be named `[path]` (single segment) for the type to match. `[[...slug]]` (catch-all) was wrong on two counts: 1. The segment name is `slug`, not `path` (Serwist expects exactly `path`). 2. The shape is `string[]` (array), not `string` (Serwist expects a single string). Per the Serwist source comment: 'Asset and chunk names must be at the top, as our path is /serwist/[path], not /serwist/[...path]' — all SW output files (sw.js, workbox-XXX.js) are flat, single segment is sufficient. The fix is a directory rename only — the route.ts content (createSerwistRoute call) is unchanged. Verification: - pnpm build now succeeds (TypeScript check passes) - The Serwist route appears in the build output as `● /serwist/[path]` prerendered with `sw.js` and `sw.js.map` static pages - `pnpm start` + Chrome: `/serwist/sw.js` will be served by the route handler and registered by --- src/app/serwist/{[[...slug]] => [path]}/route.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/app/serwist/{[[...slug]] => [path]}/route.ts (100%) diff --git a/src/app/serwist/[[...slug]]/route.ts b/src/app/serwist/[path]/route.ts similarity index 100% rename from src/app/serwist/[[...slug]]/route.ts rename to src/app/serwist/[path]/route.ts