Replies: 2 comments
-
Maybe related to my issue? #7634 |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is really awesome, thx for ur affort to our dev teams :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm just learning Next and NextAuth and I'm hoping someone might better understand what's going on here.
I'm building an app using Next 13's App Router and NextAuth for authentication through Spotify.
I'm using the
useSession()
hook in/src/app/page.tsx
, and I've defined a custom client-side component namedProviders
which wraps the NextAuth SessionProvider, as described here./src/app/components/Providers.tsx
/src/app/layout.tsx
/src/app/page.tsx
Of course, I've also defined the authentication route in
/src/app/api/auth/[...nextauth]/
:/src/app/api/auth/[...nextauth]/authOptions.ts
/src/app/api/auth/[...nextauth]/route.ts
When starting the dev server and loading the site, everything goes as expected:
When I click the Sign In button, I'm redirected to the Spotify authorization page as expected, and redirected back to
http://localhost:3000/api/auth/callback/spotify
after giving my authorization.However, rather than seeing the Sign Out page as expected, I'm greeted with a blank page, and see the following error in the console:
But then if I restart the server and reload the page, I see the Sign Out page with my name, indicating that the session variable is accessible by
![sign_out png](https://private-user-images.githubusercontent.com/60618151/239703739-160f228b-024d-47ca-ae96-0f95bb04466a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4NDQ1OTUsIm5iZiI6MTcyMTg0NDI5NSwicGF0aCI6Ii82MDYxODE1MS8yMzk3MDM3MzktMTYwZjIyOGItMDI0ZC00N2NhLWFlOTYtMGY5NWJiMDQ0NjZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI0VDE4MDQ1NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM2OTY2YjczZmNhYjEwZmE3Nzg0NDA3YTQ3MzIxNDU1MjFiNTcxMzE0NzBhNjk0NDg2NzBlYjU4NDYyMWU5MmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.aZvYnzhkG0G5xZPELvfPjDjslSJJ8xPwVpxd176JNtE)
page.tsx
, at least at first.The same thing happens when I click the Sign Out button. The sign out process happens as normal, but I return to a blank page with the same error in the console.
Does anyone have any idea why the SessionProvider would seemingly disappear after a redirect, or only work the first time?
I'm not sure if this is a bug in my code, in NextAuth, or in Next itself.
Any help would be appreciated, thanks.
Beta Was this translation helpful? Give feedback.
All reactions