From b4ccf521754a8bb299ff7b053f68a9f9c1b8d0bf Mon Sep 17 00:00:00 2001 From: JazzarKarim Date: Tue, 3 Dec 2024 17:31:43 -0800 Subject: [PATCH] full page reload --- .../middleware/00.locale-redirect.global.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/business-registry-dashboard/app/middleware/00.locale-redirect.global.ts b/business-registry-dashboard/app/middleware/00.locale-redirect.global.ts index f2d20d0..d7f9c82 100644 --- a/business-registry-dashboard/app/middleware/00.locale-redirect.global.ts +++ b/business-registry-dashboard/app/middleware/00.locale-redirect.global.ts @@ -1,12 +1,14 @@ export default defineNuxtRouteMiddleware((to) => { - // Check if the path starts with /affiliationInvitation/acceptToken and doesn't have a locale prefix if (to.path.startsWith('/affiliationInvitation/acceptToken') && !to.path.startsWith('/en-CA/')) { - // Preserve all query parameters in the redirect - const query = { ...to.query } - // Redirect to the same path but with locale prefix, maintaining query params - return navigateTo({ - path: `/en-CA${to.path}`, - query - }) + // Convert query params to URLSearchParams + const searchParams = new URLSearchParams(to.query as Record) + const queryString = searchParams.toString() + + // Construct the full URL and force a page reload + const newUrl = `/en-CA${to.path}${queryString ? '?' + queryString : ''}` + window.location.href = newUrl + + // Prevent further navigation handling + return abortNavigation() } })