fix(vue-app): use route.replace instead of router.push to trigger navigation guards (#9201)

This commit is contained in:
Thomas Beduneau 2021-05-03 10:51:18 +02:00 committed by GitHub
parent 8e2cad5a8f
commit 330e5c99bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,7 +269,7 @@ async function createApp(ssrContext, config = {}) {
// Wait for async component to be resolved first // Wait for async component to be resolved first
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
router.push(app.context.route.fullPath, resolve, (err) => { router.replace(app.context.route.fullPath, resolve, (err) => {
// https://github.com/vuejs/vue-router/blob/v3.4.3/src/util/errors.js // https://github.com/vuejs/vue-router/blob/v3.4.3/src/util/errors.js
if (!err._isRouter) return reject(err) if (!err._isRouter) return reject(err)
if (err.type !== 2 /* NavigationFailureType.redirected */) return resolve() if (err.type !== 2 /* NavigationFailureType.redirected */) return resolve()