Files
James Anderson 617605b925 fix(prerender): support string paths and missing params in getStaticPaths (#1227)
Next.js allows getStaticPaths to return paths as either
Array<{ params }> or Array<string> (see Next.js docs and
.nextjs-ref/packages/next/src/build/static-paths/pages.ts). vinext only
handled the object shape, so a fixture returning string paths crashed
the prerender phase with:

  TypeError: Cannot read properties of undefined (reading 'slug')
    at buildUrlFromParams (packages/vinext/src/build/prerender.ts:311)

This blocked ~213 Next.js deploy-suite tests
(see https://github.com/cloudflare/vinext/actions/runs/25897889733 —
middleware-general index/node-runtime, middleware-rewrites, and
middleware-trailing-slash all gated on this single build crash).

Changes:
- buildUrlFromParams: defensively throw a descriptive error when
  params itself is null/undefined, instead of crashing with a cryptic
  TypeError pointing at a dist line.
- prerenderPages (Pages Router): normalize each paths entry. Strings
  are run through the route pattern matcher to extract params, mirroring
  Next.js _routeMatcher(cleanedEntry). Missing/null params surface as
  per-route error results instead of crashing the whole prerender.
- prerenderApp (App Router): defensively guard each entry from
  generateStaticParams() against missing params with a clear error
  message in the existing try/catch.
- pages-page-data.ts (prod SSR): matchesPagesStaticPath now handles
  string entries via URL comparison and guards undefined params.
- dev-server.ts (dev SSR): same string-path + missing-params handling
  for the dev request path.
- Tests: add tests/fixtures/pages-basic/pages/string-paths/[slug].tsx
  and missing-params/[slug].tsx, with two new vitest cases asserting
  successful prerender and a per-route error result.
2026-05-15 09:34:01 +00:00
..