From 6b9da1a39b2b431ab15639f8356fb1c5e6a3336a Mon Sep 17 00:00:00 2001 From: Niels Janssen Date: Sat, 23 Sep 2023 11:59:21 +0200 Subject: [PATCH] fix: Abort SSR rendering on redirect (#438) Co-authored-by: Niels Janssen Co-authored-by: Zoey --- src/runtime/utils/url.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runtime/utils/url.ts b/src/runtime/utils/url.ts index 79816d7a..c4d7b57b 100644 --- a/src/runtime/utils/url.ts +++ b/src/runtime/utils/url.ts @@ -1,7 +1,7 @@ import { joinURL } from 'ufo' import getURL from 'requrl' import { sendRedirect } from 'h3' -import { useRequestEvent, useNuxtApp } from '#app' +import { useRequestEvent, useNuxtApp, abortNavigation } from '#app' import { useAuthState, useRuntimeConfig } from '#imports' export const getRequestURL = (includePath = true) => getURL(useRequestEvent()?.node.req, includePath) @@ -24,7 +24,11 @@ export const navigateToAuthPages = (href: string) => { if (process.server) { if (nuxtApp.ssrContext && nuxtApp.ssrContext.event) { - return nuxtApp.callHook('app:redirected').then(() => sendRedirect(nuxtApp.ssrContext!.event, href, 302)) + return nuxtApp.callHook('app:redirected').then(() => { + sendRedirect(nuxtApp.ssrContext!.event, href, 302) + + abortNavigation() + }) } }