mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix(vue-app): check whether route exists within nuxt app before replacing (#9431)
[release]
This commit is contained in:
parent
0eae970e74
commit
85615a5dc5
@ -269,7 +269,12 @@ 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.replace(app.context.route.fullPath, resolve, (err) => {
|
const { route } = router.resolve(app.context.route.fullPath)
|
||||||
|
// Ignore 404s rather than blindly replacing URL
|
||||||
|
if (!route.matched.length && process.client) {
|
||||||
|
return resolve()
|
||||||
|
}
|
||||||
|
router.replace(route, 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()
|
||||||
|
Loading…
Reference in New Issue
Block a user