-
Hello! I have configured my app with Credentials and Email providers. Now I need to redirect users to a custom url after they Sign In with the email link they get. Is it possible to do that? Thanks a lot for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello! Yes it is possible using the signIn('your-provider', {
callbackUrl: 'the link to redirect to',
}) |
Beta Was this translation helpful? Give feedback.
-
Finally I've found the correct way! :D Thanks @simonfarah !! It was just as you mentioned but where I call de signIn("email") method. I had to add the "callbackUrl" property in the email signIn method: const onSubmit = async (formData) => {
// formData.preventDefault();
const loginResult = await signIn("email", {
// para que no redirija a otra pagina cuando da error el login:
redirect: false,
// para enviar al usuario a la URL deseada cuando se loguea por mail:
callbackUrl: '/users/set-password',
// le paso las credenciales al pedido (signIn):
email: formData.email,
});
router.push("/api/auth/verify-request?provider=email&type=email");
};``` |
Beta Was this translation helpful? Give feedback.
Finally I've found the correct way! :D
Thanks @simonfarah !! It was just as you mentioned but where I call de signIn("email") method.
Documentation link
I had to add the "callbackUrl" property in the email signIn method: