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

Chapter 15 - Enabling Redirect in signOut #907

Closed
TIMN00 opened this issue Nov 2, 2024 · 3 comments
Closed

Chapter 15 - Enabling Redirect in signOut #907

TIMN00 opened this issue Nov 2, 2024 · 3 comments

Comments

@TIMN00
Copy link

TIMN00 commented Nov 2, 2024

Hi,

In Chapter 15 of the nextJS dashboard documentation, the signOut does not redirect to the login page given the sample code. I have added the following in /sidenav.tsx :

<form
                    action={async () => {
                        'use server';
                        await signOut({redirect: false});
                        redirect('/login');
                    }}
                >

Perhaps an update to the documentation should be made?

Hope this helps.

@TIMN00 TIMN00 changed the title Chapter 15 - Redirect Issues in signIn and signOut Chapter 15 - Redirect Issues in signOut Nov 2, 2024
@TIMN00 TIMN00 changed the title Chapter 15 - Redirect Issues in signOut Chapter 15 - Enabling Redirect in signOut Nov 2, 2024
@baiwfg2
Copy link

baiwfg2 commented Nov 3, 2024

If you try this example: https://next-learn-dashboard.vercel.sh , it will redirect to login page after signing out.
image

But I find the URL is not right. Should be https://next-learn-dashboard.vercel.sh/login ?

@TIMN00
Copy link
Author

TIMN00 commented Nov 3, 2024

If you try this example: https://next-learn-dashboard.vercel.sh , it will redirect to login page after signing out.

Thanks for the link ... the demo link is hit or miss for me. In Chrome, after updating, it works and redirects back to login some of the time. But doesn't work in fresh install of Firefox or Edge. So, I'm not sure that this an issue with the code or the NextAuth implemenetation in this project at this time. I'll look into this with other projects and update back here once I've gained a better understanding of things. I appreciate your reply.

@TIMN00
Copy link
Author

TIMN00 commented Nov 7, 2024

I see the following issue was raised which also provides a solution for the redirect: #904 (comment) .

Noting that auth documentation requires "Add a Route Handler under /app/api/auth/[...nextauth]/route.ts." which solves this issue. Thanks

@TIMN00 TIMN00 closed this as completed Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants