Skip to content

Commit

Permalink
full page reload
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim committed Dec 4, 2024
1 parent 5c7b97b commit b4ccf52
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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<string, string>)
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()
}
})

0 comments on commit b4ccf52

Please sign in to comment.