Fix build failure for dynamic file endpoints with trailingSlash "always"#17246
Open
astrobot-houston wants to merge 1 commit into
Open
Fix build failure for dynamic file endpoints with trailingSlash "always"#17246astrobot-houston wants to merge 1 commit into
astrobot-houston wants to merge 1 commit into
Conversation
…17241)\n\nOverride trailingSlash to 'never' in stringifyParams for endpoint routes\nwith file extensions, matching the route pattern generated by\ntrailingSlashForPath in create-manifest.ts. This fixes a regression from\n#17224 where dynamic file endpoints (e.g. [name].json.ts) with\ntrailingSlash: 'always' would fail to build with TypeError: Missing\nparameter."
1 task
🦋 Changeset detectedLatest commit: 6f92832 The changes in this PR will be included in the next version bump. This PR includes changesets to release 393 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 |
ematipico
reviewed
Jul 1, 2026
Comment on lines
+19
to
+23
| // File endpoints (e.g. [name].json.ts) should never have a trailing slash, | ||
| // even when trailingSlash is set to 'always'. This matches the route pattern | ||
| // generated by trailingSlashForPath in create-manifest.ts. | ||
| const effectiveTrailingSlash = | ||
| route.type === 'endpoint' && hasFileExtension(route.route) ? 'never' : trailingSlash; |
Member
There was a problem hiding this comment.
I don't like that we recompute this information. Since it's already computed, maybe we should pass it to downstream functions instead
Contributor
There was a problem hiding this comment.
The bot doesn't read these, so if you want to change it you can just push to the PR.
Member
There was a problem hiding this comment.
Yeah but what you think? Does it make sense? Is it possible? Asking for feedback
Contributor
There was a problem hiding this comment.
Where else is it computed?
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
[name].json.ts) no longer get a trailing slash appended during build whentrailingSlash: "always"is configured. This was causingTypeError: Missing parameterbecause the generated path/api/foo.json/didn't match the route's own regex pattern (which already used'never'for file endpoints after Fix trailing slash handling for dynamic file endpoints in dev mode #17224).stringifyParams: overridetrailingSlashto'never'when the route is an endpoint with a file extension, matching whattrailingSlashForPathproduces increate-manifest.ts.Closes #17241
Testing
packages/astro/test/units/routing/generator.test.ts:trailingSlash: 'always'produces path without trailing slashDocs
trailingSlash: "always"with file endpoints.