Repository navigation
fix: combine prerendered trailing slash redirects into as few Vercel routes as possible - #17523
Draft
elliott-with-the-longest-name-on-github wants to merge 1 commit into
Conversation
…ew routes as possible
elliott-with-the-longest-name-on-github
added this pull request to stack #17524
October 22, 2026 18:17
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/0b7b25486d1115a4e24bcb5d9e4adac8ab330333Open in |
🦋 Changeset detectedLatest commit: 0b7b254 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #17522, which covers apps where every route uses the same
trailingSlash. This PR makes the fallback for everything else (mixed options and'ignore') much smaller.Currently the adapter adds two routes per prerendered page. One of them,
{ src: path, dest: counterpart }, is unnecessary: Vercel strips trailing slashes before it looks up a static file, so/foo/already findsfoo. Worse, because that route doesn'tcontinue, it stops the routes after it from running. For example, prerendered pages skipped the route that sets the skew protection cookie (going by the proxy source; I haven't tested this with skew protection turned on).The redirects themselves were also buggy:
/blog/café/never matched its redirect./v1.2/also matched/v1x2/.What changed
^/(blog/a|blog/b|…)/$→/$1. A new route starts whenever one gets close to Vercel's 4096-character limit onsrc. A thousand blog posts now take about 7 routes instead of 2,000.encodeURI, the same way Kit's prerenderer does it, and regex-escaped. The routes arecaseSensitive, matching Kit's router.There's one small gap left: a client that sends lowercase hex escapes (
%c3%a9) won't match a redirect. The page is still served, it just isn't redirected. Browsers send uppercase.Tests
basichas new dynamic prerendered routes for both trailing slash modes, with build and platform tests. The redirect test fails onmainfor thecafépage.