Skip to content

Commit

Permalink
fix(vue-app): check whether route exists within nuxt app before repla…
Browse files Browse the repository at this point in the history
…cing (#9431)

[release]
  • Loading branch information
danielroe authored and pi0 committed Jun 14, 2021
1 parent 0eae970 commit 85615a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vue-app/template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ async function createApp(ssrContext, config = {}) {

// Wait for async component to be resolved first
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
if (!err._isRouter) return reject(err)
if (err.type !== 2 /* NavigationFailureType.redirected */) return resolve()
Expand Down

0 comments on commit 85615a5

Please sign in to comment.