Next.js Discord

Discord Forum

Nextjs Authentication

Unanswered
Japanese Chin posted this in #help-forum
Open in Discord
Japanese ChinOP
Dears,

I am using next-auth@beta lib for the authentication. It throw the error:

Error: NEXT_REDIRECT
at getRedirectError (d:\projects\src\client\components\redirect.ts:15:16)
at getRedirectError (d:\projects\src\client\components\redirect.ts:40:8)
at async authenticate (d:\projects\2025\finance-web\2025-finance-web\app(authen)\login\actions\action.ts:21:6)
13 | statusCode: RedirectStatusCode = RedirectStatusCode.TemporaryRedirect
14 | ): RedirectError {
15 | const error = new Error(REDIRECT_ERROR_CODE) as RedirectError
| ^
16 | error.digest = ${REDIRECT_ERROR_CODE};${type};${url};${statusCode};
17 | return error
18 | } {
digest: 'NEXT_REDIRECT;push;http://localhost:3000/login?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2Fdashboard;307;'
}

It appears from this function:

export async function authenticate(
prevState: string | undefined,
formData: FormData
) {
try {

await signIn("credentials", formData);

} catch (error) {
console.log("----------------------------------");
console.log(error);
if (error instanceof AuthError) {
switch (error.type) {
case "CredentialsSignin":
return "Invalid Credentials";
default:
return "Something went wrong";
}
}
throw error;
}
}


please help me to fix it

0 Replies