Skip to content

Commit

Permalink
fix: redirect without unresolved promise
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Jan 16, 2018
1 parent 97d70f4 commit 24185c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/app/client.js
Expand Up @@ -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)
})

Expand Down
9 changes: 5 additions & 4 deletions lib/app/utils.js
Expand Up @@ -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')
}
}
}
Expand Down

0 comments on commit 24185c9

Please sign in to comment.