From 6434f53448c8db11d5981a6ef50113d38dded866 Mon Sep 17 00:00:00 2001 From: Timbological <31364357+Timbological@users.noreply.github.com> Date: Wed, 11 Oct 2023 20:57:43 +1100 Subject: [PATCH] fix: made `globalAppMiddleware` more intuitive Co-authored-by: Zoey --- src/runtime/middleware/auth.ts | 2 +- src/runtime/utils/url.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/runtime/middleware/auth.ts b/src/runtime/middleware/auth.ts index db4eb8d3..9eda419d 100644 --- a/src/runtime/middleware/auth.ts +++ b/src/runtime/middleware/auth.ts @@ -69,7 +69,7 @@ export default defineNuxtRouteMiddleware((to) => { * - avoid the `Error [ERR_HTTP_HEADERS_SENT]`-error that occurs when we redirect to the sign-in page when the original to-page does not exist. Likely related to https://github.com/nuxt/framework/issues/9438 * */ - if (authConfig.globalAppMiddleware.allow404WithoutAuth) { + if (authConfig.globalAppMiddleware.allow404WithoutAuth || authConfig.globalAppMiddleware === true) { const matchedRoute = to.matched.length > 0 if (!matchedRoute) { // Hands control back to `vue-router`, which will direct to the `404` page diff --git a/src/runtime/utils/url.ts b/src/runtime/utils/url.ts index c4d7b57b..2d2cae44 100644 --- a/src/runtime/utils/url.ts +++ b/src/runtime/utils/url.ts @@ -71,5 +71,7 @@ export const determineCallbackUrl = >(authCon return getOriginalTargetPath() } } + } else if (authConfig.globalAppMiddleware === true) { + return getOriginalTargetPath() } }