From 2e00dab95d3fefeab92c19cedb046ae2bb10879c Mon Sep 17 00:00:00 2001 From: Mohammd Alamgir Siddiqui Date: Mon, 3 May 2021 20:32:20 +0100 Subject: [PATCH] fix(vue): use correct history mode when doing ssr to avoid errors (#23255) resolves #23254 --- packages/vue-router/src/router.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vue-router/src/router.ts b/packages/vue-router/src/router.ts index 3fd1ec43f0..dd6b67c0ea 100644 --- a/packages/vue-router/src/router.ts +++ b/packages/vue-router/src/router.ts @@ -39,8 +39,10 @@ export const createIonRouter = (opts: IonicVueRouterOptions, router: Router) => * about the replace action in opts.history.listen * but we can check to see if the latest routing action * was a replace action by looking at the history state. + * We need to use opts.history rather than window.history + * because window.history will be undefined when using SSR. */ - const replaceAction = history.state.replaced ? 'replace' : undefined; + const replaceAction = opts.history.state.replaced ? 'replace' : undefined; handleHistoryChange(to, action || replaceAction, direction); currentNavigationInfo = { direction: undefined, action: undefined };