-
Notifications
You must be signed in to change notification settings - Fork 927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add onRedirect hook to pre-process URLs before redirection #185
Conversation
Nice enhancement. Can we support more than one listener (array) or maybe wouldn't be better to rename the hook to something like |
@pi0 I changed it so it supports multiple listeners like |
Sorry for the late check. Thanks :) |
I don't think having multiple events for redirect is a good idea, if the last defined event hasn't a return it could mess it up all In case of Or check if the executed function have some vale to set to redirect destination... What do you think? |
@d0whc3r I agree. But we can think of them like middleware functions :) |
hello $auth undefiend |
app.$auth.onRedirect is not a function |
It's still is not released. In nuxt.config.js ->
|
when will this be released? |
I did not define redirect in the
|
When this will be released ? 6 months without any major release for a such package, this is not serious... |
Co-authored-by: Paul Gascou <[email protected]>
Regarding https://auth.nuxtjs.org/api/auth.html#onredirect-handler |
missed the documentation ^^) |
Try this
|
nuxt.config.js :
plugins/auth.js :
|
To allow users selecting their locale on the login screen and make their choice follows to the app, I simply added the following plugin (@nuxtjs/auth:4.9.1 and nuxt:2.14.7) plugins/auth.js : export default function({app, $auth }) {
$auth.onRedirect((to, from) => {
// change `to` by returning a new value
return app.localePath(to);
})
} |
Hi everybody, thanks for your help, I've been able to implement your suggestion, but when redirect is done an error log is shown in console:
I thought it was still using the old redirection, but i changed the redirect endpoint and it is done correctly. How to avoid the error mesage? |
This is another proposal to address #162
It adds an
onRedirect
hook that can be defined in a plugin in order to pre-process the URL before the redirect happens.To use this with nuxt-i18n, you could do something like this: