Skip to content

Commit

Permalink
testing a new middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim committed Nov 28, 2024
1 parent 108deda commit 3617447
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default defineNuxtRouteMiddleware((to) => {
// Only proceed if we're hitting the affiliation invitation route
if (!to.path.includes('/affiliationInvitation/acceptToken/')) {
return
}

// Check if the path already has a locale prefix
const hasLocale = /^\/[a-zA-Z]{2}-[a-zA-Z]{2}\//.test(to.path)
console.log('hasLocale', hasLocale)

if (!hasLocale) {
// Add en-CA to the beginning of the path
console.log('to', to.path)
const newPath = `/en-CA${to.path}`
console.log('newPath', newPath)
return navigateTo(newPath, { redirectCode: 301 })
}
})

0 comments on commit 3617447

Please sign in to comment.