From 24185c97e7a8173932b3d6d0ed19799d5e983c38 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 16 Jan 2018 10:04:40 +0330 Subject: [PATCH] fix: redirect without unresolved promise --- lib/app/client.js | 3 +++ lib/app/utils.js | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 456eac17760e..a289c9f8d26b 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -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) }) diff --git a/lib/app/utils.js b/lib/app/utils.js index 5049a7e74953..c9836241509f 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -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') } } }