Hi,
I’m using nextjs 14 with app route. I want to redirect the user to a specific path after login, such as /dashboard
.
In the api route:
Firstly, I tried to add returnTo
in handleLogin function, it doesn’t work.
Then, I also tried to add afterCallback function to redirect user to the path according to this document , it throw this error
Codes are below:
// app/api/auth/[auth0]/route.js
import { handleAuth, handleCallback, handleLogin } from "@auth0/nextjs-auth0";
import { redirect } from "next/navigation";
export const GET = handleAuth({
// login: handleLogin({
// returnTo: "/dashboard",
// }),
callback: handleCallback({
afterCallback: () => {
redirect("/dashboard");
},
}),
})