Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signIn function not redirecting to custom signIn page #12658

Open
iltan987 opened this issue Feb 16, 2025 · 0 comments
Open

signIn function not redirecting to custom signIn page #12658

iltan987 opened this issue Feb 16, 2025 · 0 comments
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@iltan987
Copy link

Environment

OS: Windows 10 Version 22H2 (OS Build 19045.5487)
Node.js: v23.6.0
npm: 11.1.0

next: 15.1.7
react: 19.0.0
next-auth: 5.0.0-beta.25

Reproduction URL

https://github.com/iltan987/custom_page_issue

Describe the issue

As I understood, signIn function with no parameters, should redirect to signIn page. If the signIn page is customized in auth.ts, signIn function should redirect to new one but it doesn't, yet it redirects to '/api/auth/signin' page.
If you refresh the wrongly redirected one, you get the correct URL but needs a refresh.
Also, redirected page has the content of correct one.
So, just the URL is wrong. Page is correct.
You can use https://custompageissue.vercel.app to check

src/auth.ts:

import NextAuth from "next-auth";
import Google from "next-auth/providers/google";

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [Google],
  pages: {
    signIn: "/login",
  },
});

src/app/middleware.ts:

export { auth as middleware } from "@/auth";

src/app/api/auth/[...nextauth]/route.ts:

import { handlers } from "@/auth";
export const { GET, POST } = handlers;

src/app/login/page.tsx

const Login = () => {
  return (
    <div>
      <h1>Login</h1>
    </div>
  );
};
export default Login;

How to reproduce

Configure custom signIn page.
Call signIn function with no parameter from anywhere in your page.
It will be redirected to /api/auth/signin page instead of customized one.

Expected behavior

After configuring custom signIn page and calling signIn function, it should redirect to the one in customized signIn (e.g. /login) instead of /api/auth/signin

@iltan987 iltan987 added bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

1 participant