diff --git a/lib/core/auth.js b/lib/core/auth.js index da2dc6560..2ac732e8c 100644 --- a/lib/core/auth.js +++ b/lib/core/auth.js @@ -46,15 +46,19 @@ export default class Auth { } // Call mounted for active strategy on initial load - await this.mounted() - - // Watch for loggedIn changes only in client side - if (process.browser && this.options.watchLoggedIn) { - this.$storage.watchState('loggedIn', loggedIn => { - if (!routeOption(this.ctx.route, 'auth', false)) { - this.redirect(loggedIn ? 'home' : 'logout') - } - }) + try { + await this.mounted() + } catch (e) { + + } finally { + // Watch for loggedIn changes only in client side + if (process.browser && this.options.watchLoggedIn) { + this.$storage.watchState('loggedIn', loggedIn => { + if (!routeOption(this.ctx.route, 'auth', false)) { + this.redirect(loggedIn ? 'home' : 'logout') + } + }) + } } }