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() createApp()
.then(mountApp) .then(mountApp)
.catch(err => { .catch(err => {
if (err.message === 'ERR_REDIRECT') {
return // Wait for browser to redirect...
}
console.error('[nuxt] Error while initializing app', err) console.error('[nuxt] Error while initializing app', err)
}) })

View File

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