Fix static build crash for file-extension endpoint routes with trailingSlash: "always"#17320
Merged
Conversation
… in stringifyParams When trailingSlash is 'always', stringifyParams (via getRouteGenerator) was appending a trailing slash to endpoint paths with file extensions (e.g. /og/foo.png/). But the route pattern for such endpoints is generated with trailingSlash 'never' by trailingSlashForPath() in create-manifest.ts (e.g. /^\/og\/(.*?)\.png$/). This mismatch caused getParams() to fail matching, leading to NoMatchingStaticPathFound during static builds. Apply the same trailingSlashForPath logic in stringifyParams: when the route is an endpoint with a file extension, force trailingSlash to 'never'. Fixes #17306
|
|
Probably a dupe of #17246. |
matthewp
approved these changes
Jul 9, 2026
matthewp
approved these changes
Jul 9, 2026
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.
Changes
[...slug].png.ts) no longer fail withNoMatchingStaticPathFoundduringastro buildwhentrailingSlash: "always"is set.stringifyParams()now mirrors thetrailingSlashForPath()logic already used in route pattern generation: when a route is an endpoint with a file extension, trailing slash is forced to'never', so generated paths (e.g./og/foo.png) match the route pattern (e.g./^\/og\/(.*?)\.png$/). The mismatch affected both ASCII and non-ASCII params.Closes #17306
Testing
packages/astro/test/units/routing/get-params.test.tscovering:trailingSlash: 'always'— path must not get a trailing slash and must match the route pattern.[name].json) with the same config.Docs