fix: redirect without unresolved promise

This commit is contained in:
Pooya Parsa 2018-01-16 10:04:40 +03:30
parent 97d70f46c6
commit 24185c97e7
2 changed files with 8 additions and 4 deletions

View File

@ -60,6 +60,9 @@ Vue.config.errorHandler = function (err, vm, info) {
createApp()
.then(mountApp)
.catch(err => {
if (err.message === 'ERR_REDIRECT') {
return // Wait for browser to redirect...
}
console.error('[nuxt] Error while initializing app', err)
})

View File

@ -153,10 +153,11 @@ export async function setContext(app, context) {
})
}
if (process.client) {
window.location = path
return new Promise((resolve) => {
// Wait for browser to redirect...
})
// https://developer.mozilla.org/en-US/docs/Web/API/Location/replace
window.location.replace(path)
// Throw a redirect error
throw new Error('ERR_REDIRECT')
}
}
}