-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Page redirection fails due to SSR mismatch #1382
Comments
|
Normal SSR
Current VuePress "SSR"
|
I have created a plugin vuepress-plugin-dehydration to temporarily workaround this issue. |
Feature request
What problem does this feature solve?
Sometimes, we need to redirect to another location before the page finishes rendering. For example, in the following snippet,
vuepress/packages/@vuepress/core/lib/app/redirect.js
Lines 23 to 50 in 1850be7
VuePress will try to redirect unknown request
/foo
to/foo.html
and/foo/
. Other scenarios include redirecting/
to/zh/
or/en/
based on navigator language.The snippet referenced above will work fine for most of the conditions. But if the page needs redirecting before rendering starts, uses server-side rendering and the pages before and after redirecting do not share an identical structure, this will lead to the problem called SSR Mismatch.
Summarize the bug-like problem as follow.
The server-side rendered pages need a
hydration
stage to be fully functional and thehydration
stage needs corresponding DOM and VDOM structure (a correctly server-side rendered website could easily achieve this).But, when at least one of DOM and VDOM changes before
hydration
, DOM and VDOM mismatch will happen, especially in production distribution ofVue
where the mismatch warning is indirect and there-rendering
fallback is removed (see this issue in theVue
repository).Redirecting may be the most reasonable way for such condition to happen as the VDOM is changed and the pages before and after redirecting do not have identical VDOM structure.
The feature request aims to solve this problem.
What does the proposed API look like?
What I propose here is that VuePress should handle the problem internally for end users and plugin developers, for example, by postponing the redirection.
If it can't be solved gracefully, at least, the document should explicitly point this caveat out.
How should this be implemented in your opinion?
I mentioned bug-like above because I know it is not a bug of
Vue Server Renderer
orVue Router
. Instead, it should be addressed by the app itself. But developers may easily ignore this and waste much time debugging because the bug only exists inbuild
mode with server-side rendering enabled. Even VuePress' official code (the snippet referenced above) has such problem as well.Are you willing to work on this yourself?
I'm willing to participate in. Actually, I have experimented for a while but can't solve the problem without glitch. So, I post it out and seek help.
The text was updated successfully, but these errors were encountered: