-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: prevent incorrect trailing slash redirect for prerendered root page when paths.base
is set
#10763
Conversation
🦋 Changeset detectedLatest commit: 6cd4623 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
paths.base
is setpaths.base
is set
paths.base
is setpaths.base
is set
const { pathname } = new URL(original_url, 'http://dummy'); | ||
const { pathname, search } = new URL(original_url, 'http://dummy'); | ||
|
||
// if `paths.base === '/a/b/c`, then the root route is `/a/b/c/`, |
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.
Can we add an explanation of why that is? It seems quite surprising to me that we would ignore the trailing slash option for the root page when base is set. I remember putting a lot of effort into an earlier version of Vite to allow it to work without a trailing slash and I don't understand why we'd have this new behavior
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.
The original explanation is in this previous PR #9343 However it was not applied in vite preview, hence this PR. But I think this got removed in 2.0 because vite always does it? I have to check
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.
Oops, sorry, I didn't mean to comment on a closed PR. I was on mobile and thought I was looking at #11357
fixes #9982
This PR reinforces the behaviour of always redirecting
/base
to/base/
in #9343 by:/base/
to/base
(because no trailing slash option is set).vite preview
and visiting the prerendered root page without the trailing slash/base
, correctly redirect to the trailing slash path/base/
.vite preview
trailing slash redirectDebating adding a test for this because it would require setting up another test project just to test the behaviour of prerendering a root page with paths.base set.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.