N
Nuxt6mo ago
Thou Blue

How can i load same page for two separate urls?

I have working url /login. Now my new requirement wants me to load the same page but with different urls /login-fb or /login-google or any other way letting the user know from where they were redirected. Everything needs to be same but the url. I have tried using middleware to handle such redirection, but the new page doesn't exist so has 404 error. I want to handle this properly so that in future if other such links are added, there will be less files to modify. Thanks in advance.
No description
3 Replies
manniL
manniL6mo ago
you can use alias via definePageMeta to set static aliases or add them already at build step via pages:extend hook
Thou Blue
Thou BlueOP6mo ago
Thanks @manniL / TheAlexLichter ,
///login.vue
definePageMeta({
middleware: 'guest',
alias: ['/login-google']
})

///middleware
if (fromUrl.includes('-google')) {
return navigateTo(to.path + '-google')
}
///login.vue
definePageMeta({
middleware: 'guest',
alias: ['/login-google']
})

///middleware
if (fromUrl.includes('-google')) {
return navigateTo(to.path + '-google')
}
manniL
manniL6mo ago
You can even use the redirect property in definePageMeta That might make it even easier!
Want results from more Discord servers?
Add your server