From c50c4d4deb661e2432c2e9482929e6ea7f41950f Mon Sep 17 00:00:00 2001 From: BobChao87 Date: Thu, 23 Sep 2021 02:51:53 -0700 Subject: [PATCH] history doesn't exist in SSR, so don't call Redirects with too many path parts where breaking, now they take users to broken parts of the old Oengus when redirecting --- middleware/oengus-v1-redirect.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/oengus-v1-redirect.ts b/middleware/oengus-v1-redirect.ts index af600822..79ada5e1 100644 --- a/middleware/oengus-v1-redirect.ts +++ b/middleware/oengus-v1-redirect.ts @@ -37,7 +37,7 @@ const oengusV1Redirect: Middleware = function ({ $config, route, redirect, from // If you hit back, you get the page BEFORE the page you clicked the link on. // This makes sure we push an entry to the history stack to go back to. // If we start having doubled up history, this history.pushState is a good candidate to check. - history.pushState((Number.parseFloat(history.state) + 1).toFixed(3), document.title, from.fullPath); + globalThis.history?.pushState((Number.parseFloat(history.state) + 1).toFixed(3), document.title, from.fullPath); redirect(`https://${$config.env.DOMAIN_V1}/${to.join('/')}`); } };