I’m working with Supabase and next-js to create a platform with user identities. When logging in, the user is supposed to be redirected to a dashboard page. However, this redirect doesn’t occur.
The only solution I’ve found is to wrap both in a setTimout; Suggesting that the process of logging in has not had enough time to process. The only problem with this is that next redirect throws an error, which is fine outside of the timeout but not inside (as it crashes). Another solution that was mentioned to me was to wrap my function in a try catch, with also was to no avail.
Thanks in advance!
Here is the login function:
"use server"
const email = formData.get("email")
const password = formData.get("password")
const supabase = createClient();
try {
const { error } = await supabase.auth.signInWithPassword({
email,
password,
});
if (error) {
return redirect("/login?error=" + error.message);
}
} catch (error) {
}
revalidatePath('/dashboard/classes', 'page')
redirect("/dashboard/classes")
ian loftis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.