Skip to content
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

fix(vue-app): check whether route exists within Nuxt app before replacing #9431

Merged
merged 2 commits into from Jun 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/vue-app/template/index.js
Expand Up @@ -270,7 +270,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