You are getting "window is not defined" because you are trying to call a signOut function (which requires a browser window) in a session callback inside [...nextauth].js.
[...nextauth].js lives in pages/api/auth, and pages/api in Next.js are the server functions. You can look up the documentation on signOut.
If you want to logout a user from the session callback, you should probably use POST /api/auth/signout. Call it as you would a regular endpoint. This is used by signOut() internally.
I'm not sure if it's gonna work, but it's worth exploring. Let me know how you did :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You are getting "window is not defined" because you are trying to call a
signOut
function (which requires a browser window) in asession
callback inside[...nextauth].js
.[...nextauth].js
lives inpages/api/auth
, andpages/api
in Next.js are the server functions. You can look up the documentation on signOut.If you want to logout a user from the session callback, you should probably use POST /api/auth/signout. Call it as you would a regular endpoint. This is used by
signOut()
internally.I'm not sure if it's gonna work, but it's worth exploring. Let me know how you did :)