How to prevent redirect to /api/auth/verify-request?provider=resend&type=email after Magic Link? #11101
Replies: 2 comments 1 reply
-
Hey @subproject22 You will be able to achieve this by using the "use server";
import { signIn } from "@/auth";
export const handleEmailSignIn = async (email: string) => {
try {
await signIn("nodemailer", {
email,
callbackUrl: "/dashboard", // URL to redirect after successful sign-in
redirect: false, // Prevent default redirect behavior
});
} catch (error) {
throw error;
}
}; const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
await handleEmailSignIn(email); // Server Action
toast("Check your email for the Magic Link");
} catch (error) {
console.error(error);
}
}; If you want to redirect users to custom pages, you can specify these pages in your ./auth.ts configuration file like so: pages: {
signIn: "/auth/sign-in",
error: "/auth/auth-error",
}, For more details, you can check the documentation here: Custom Pages Hope this helps 🤗 |
Beta Was this translation helpful? Give feedback.
-
There used the be possibility to customise this route with But I'm not sure if it still available in v5. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
After I sent email with
resend
provider, it redirects me to/api/auth/verify-request?provider=resend&type=email
.Why it's doing it? I don't wan't to go anywhere. I want to show user success message on same page, or redirect to any other page I want. How can I do that? I've tried to do that in
signIn
action and then insendVerificationRequest
but it's not working or throwing redirect error (triedredirect
)Beta Was this translation helpful? Give feedback.
All reactions