Skip to content

Next Auth middleware does not update session #9194

Closed Answered by MoWael11
MoWael11 asked this question in Help
Discussion options

You must be logged in to vote

I managed to resolve the issue by adding the SessionProvider into the root layout. I created a file named providers.tsx that contains the SessionProviderClient component, then enveloped the entire application within it:

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang='en'>
      <Providers>
        <body className={inter.className}>{children}</body>
      </Providers>
    </html> 
  )
}

I think that without the session provider, the session wasn't able to update itself effectively. However, by including the SessionProvider, the middleware now updates seamlessly. I've updated also the Reproduction Url

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MoWael11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
4 participants
Converted from issue

This discussion was converted from issue #9183 on November 20, 2023 09:25.