Skip to content

fix(prerender): build getPrerenderPaths() URLs from complete route params - #726

Merged
cpojer merged 2 commits into
mainfrom
fix/prerender-path-params
Nov 6, 2026
Merged

cpojer merged 2 commits into
mainfrom
fix/prerender-path-params

Conversation

@magurotuna

Copy link
Copy Markdown
Member

getPrerenderPaths() entries were turned into URLs by plain string replacement, so some builds silently prerendered the wrong page:

Pattern Entry Before After
/u/:idx/:id { id: '1', idx: '2' } /u/1x/:id /u/2/1
/blog/:slug { slg: 'hello' } /blog/:slug build error
/blog/:slug { slug: 'a b?c' } /blog/a b?c /blog/a%20b%3Fc

Now:

  • URLs are built like routeUrl(), with each value encoded.
  • An invalid entry fails the build. The error shows which file and which entry caused it:
    pages/posts/[slug].server.ts getPrerenderPaths()[1]: Missing route param "slug".
    
  • A prerendered page for /blog/a%20b is now written to dist/client/blog/a b.html. Static hosts look for that file when serving the URL.

Apps that relied on the old behavior (missing keys, or / in a [slug] value) now get a build error instead of a wrong page.

…rams

Prerender URLs for dynamic pages were built by plain string replacement
of `:name`, which filled the wrong segment (`:id` inside `:idx`), ignored
misspelled keys, and left values unencoded.

Build them with interpolateRouteParams() instead. An invalid entry now
fails the build with the server file and entry index, and prerendered
files are written at the decoded path static hosts look up.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-prerender-path-params-void-cloud.voidzero-docs.workers.dev (commit c547ce1)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://50301801-void-cloud.voidzero-docs.workers.dev c547ce1 2026-11-06T06:12:17.957Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://65efddb4-void-cloud.voidzero-docs.workers.dev df84ae0 2026-11-06T04:57:42.468Z Visit the dashboard ↗

cpojer
cpojer previously approved these changes Nov 6, 2026

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thank you.

@cpojer
cpojer marked this pull request as ready for review November 6, 2026 06:10
@cpojer
cpojer merged commit 8141a8d into main Nov 6, 2026
18 checks passed
@cpojer
cpojer deleted the fix/prerender-path-params branch November 6, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants