-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(dev): preserve query params when base path is stripped #15124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(dev): preserve query params when base path is stripped #15124
Conversation
🦋 Changeset detectedLatest commit: 9926b6b The changes in this PR will be included in the next version bump. 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 |
|
@florian-lefebvre can you review my PR? please give me feedback |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes |
|
Hi, some tests are not passing. Can you fix them first? |
df5043d to
9aa7899
Compare
|
@florian-lefebvre I’ve added the test screenshot; please review it again. |
Fixes issue where requests to /base?query=test would return 404 when trailingSlash is set to 'never' or 'always'. The baseMiddleware now ensures URLs always start with '/' after stripping the base path, preserving query parameters for proper route matching. Fixes withastro#15095
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
e9dd2ac to
aecd817
Compare
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
|
Hi @florian-lefebvre would you review once more? |
florian-lefebvre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are flaky, nothing to worry about. Thank you!

Fixes #15095
Changes
Updated
baseMiddlewareto ensure that after stripping the base path, the resulting URL always starts with/when it's not empty. This preserves query parameters and ensures proper URL parsing downstream.After:
packages/astro/src/vite-plugin-astro-server/base.ts: Added logic to prepend/when the stripped URL doesn't start with/and isn't emptypackages/astro/src/vite-plugin-astro-server/request.ts: Already had normalization logic that handles the empty string pathname case (no changes needed)packages/astro/test/units/routing/trailing-slash.test.js: Test already exists for this scenario (issue Query params trigger 404 error in dev #15095)Testing
The fix ensures that:
/base?query=test→ strips to/?query=test→ normalizes to empty string pathname for route matching ✅/base→ strips to empty string → normalizes correctly ✅/base/→ strips to/→ normalizes correctly ✅Docs
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=42954461