fix(nuxt): await for `router.push` on ssr (#4491)

This commit is contained in:
Anthony Fu 2022-04-22 23:37:52 +08:00 committed by GitHub
parent 650d12fa9c
commit 46ecbc558d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -167,8 +167,6 @@ export default defineNuxtPlugin((nuxtApp) => {
})
if (process.server) {
router.push(nuxtApp.ssrContext.url)
router.afterEach(async (to) => {
if (to.fullPath !== nuxtApp.ssrContext.url) {
await navigateTo(to.fullPath)
@ -177,6 +175,10 @@ export default defineNuxtPlugin((nuxtApp) => {
}
try {
if (process.server) {
await router.push(nuxtApp.ssrContext.url)
}
await router.isReady()
} catch (error) {
callWithNuxt(nuxtApp, throwError, [error])