I have the following server action login.ts:
export async function login(formData: FormData) {
// validate formData and interact with database
redirect("/dashboard");
}
Which I call from my server component page.tsx:
import { login } from "@/actions/login";
import { redirect } from "next/navigation";
export default async function Page() {
return (
<>
<!-- HTML stuff -->
<form action={login}></form>
</>
)
The problem is that after submitting the form, the server action doesn't redirect the user to the dashboard page. How can I fix this?