Skip to content

Error: NEXT_REDIRECT #9389

Dec 14, 2023 · 16 comments · 24 replies
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: 16 comments 24 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
2 replies
@maxpaleo
Comment options

@kavinask007
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@LMarcinkowski
Comment options

@lorenzobrito
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Saiguna7
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
2 replies
@andresgutgon
Comment options

@obasekiosa
Comment options

Comment options

You must be logged in to vote
3 replies
@OzeroDev
Comment options

@jaggerharness
Comment options

@Kamahl19
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
1 reply
@Saiguna7
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet