-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Redirect to login page #5296
Comments
It is probably expected that the code
will also affect the redirect |
Could you provide a small reproduction to help us confirm that the redirect does not take |
Thank you for bringing this issue attention. I indicated above that in the url code itself, the transition does not contain basePath at all. I think it should be something like this (with
Here is what it looks like in code. I don't have much experience in creating public pull requests, so I can't fix this bug myself yet, unfortunately. |
Here is how I solved the problem. Using the onUnauthenticated parameter. .env
_app.js
However, basePath is still expected to work correctly for all parts of the system. |
@ThangHuuVu I can confirm this bug. I just encountered it. <SessionProvider
session={session}
basePath={`${env.NEXT_PUBLIC_APP_BASE_PATH}/api/auth`}
>
<main className={fonts.className}>
<Component {...pageProps} />
</main>
</SessionProvider> {
reactStrictMode: true,
swcMinify: true,
basePath: env.APP_BASE_PATH,
async redirects() {
return [
{
source: "/",
destination: env.APP_BASE_PATH,
basePath: false,
permanent: false,
},
{
source: "/api/auth/:path*",
destination: `${env.APP_BASE_PATH}/api/auth/:path*`,
basePath: false,
permanent: false,
},
];
},
} |
@stychu and @ThangHuuVu I can also confirm this bug.
Would this make sense? |
@mscerri Your merge to v4 was reverted by this commit: a83573e#comments Do you know if it's possible to access your fix right now instead of creating a redirect or using the workarounds ? Thanks |
It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks! |
To keep things tidy, we are closing this issue for now. If you think your issue is still relevant, leave a comment and we might reopen it. Thanks! |
We are having the exact same scenario as @mscerri and still facing this issue, because of the revert. Can someone help fixing this issue? |
hi all, if you are still having the issue, please open a new issue with a proper reproduction so that we can take a deeper look 🙏 |
Question 💬
Hi I am using next with a different basepath. I need to use useSession to check authorization, and if it is not there, redirect to the authorization page. How can I change the logic?
The code https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/react/index.tsx#L102 explicitly redirects to /api/auth/signin:
but I have it might be: /custompath/api/auth/signin.
How to reproduce ☕️
I have nginx running with a proxy pass that is configured to serve a next application at /custompath.
Thus, all actions are expected to take place relative to /custompath:
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
The text was updated successfully, but these errors were encountered: