Skip to content

Error: NEXT_REDIRECT #9389

Discussion options

You must be logged in to vote

EDIT - I figured out a solution, add the following code to the catch block in the authenticate action:

import { isRedirectError } from "next/dist/client/components/redirect";

if (isRedirectError(error)) {
    throw error;
}

I am slightly confused why it's necessary to throw e; when I want to be able to send messages back to the client:

// action.ts

"use server";

import { AuthError } from "@auth/core/errors";
import { signIn } from "@motors.bid/auth";

export async function authenticate(
	prevState: string | undefined,
	formData: FormData,
) {
	try {
		const success = await signIn("credentials", formData);
		console.log({ prevState, success });
		return undefined;
	} catch (error) {
		c…

Replies: 7 comments 13 replies

Comment options

You must be logged in to vote
13 replies
@Sevansi
Comment options

@taylor-lindores-reeves
Comment options

Answer selected by Sevansi
@Sevansi
Comment options

@Vardhan1342
Comment options

@Sevansi
Comment options

@Jee-on
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet