#NextAuth v5 not redirecting to provider auth

1 messages · Page 1 of 1 (latest)

subtle ledge
#

Please take a look at the video. It seems like authjs is not redirecting to the authorization url automatically.

"next": "^15.0.1"
"next-auth": "5.0.0-beta.25"

signIn server action

import { signIn as naSignIn, signOut as naSignOut } from "~/server/auth";
import { redirect } from 'next/navigation'

export async function signIn(
  provider: string,
  credentials?: z.infer<typeof userLoginForm>,
) {
  try {
    if (provider == "credentials") {
      await naSignIn(provider, { ...credentials});
    } else await naSignIn(provider);
  } catch (error) {
    if (isRedirectError(error)) {
      return error.message;
    } else if (error instanceof CredentialsSignin) {
      return error.cause;
    } else if (error instanceof ZodError) {
      return error.message;
    } else if (error instanceof Error) {
      console.log(error);
      return error.message;
    } else if (typeof error === "string") {
      return error;
    } else {
      return "something went wrong";
    }
  }
  if (provider == "credentials") redirect("/", RedirectType.replace)
}

royal oysterBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

subtle ledge
#

update: so i tried isolating the issue by creating a signin function just for github and it works

export async function signInGitHub() {
  await naSignIn("github");
}