Frequent logouts
I am using kinde auth with nextjs and react,but for some reasons I keep getting logged out intermittently.
I can see the refresh tokens and access token setup properly in the cookies.
At some point the Kinde auth provider hits this api, api/auth/setup and its returns not logged in.
So I have to click on login again but authentication flow is not there, it will login me straight without email and passcode.
What could be the reasons for the intermittent sign outs , I am pretty sure I have set the id token , access token , refresh token for a 7 days , 30 days and 6 months.
Any help is appreciated! Thanks
6 Replies
What does your middleware setup look like?
Something like this:
For passive refreshing of tokens to work when expiry is hit we need middleware to run on all paths - see the documentation
An example matcher would be:
You can opt out paths by extending the matcher further, or by using the
publicPaths
option on middleware. For an example of that see hereKinde docs
Next.js App Router SDK
Our developer tools provide everything you need to get started with Kinde.
@Yoshify Does it have something to do with intermittent logouts, I am experimenting by removing await refreshTokens() now
Are you using pages router or app router?
refreshTokens
has no effect in app router environments.
If you set up the middleware to run on all paths the effect of refreshTokens
will be handled for you automatically in the background when tokens approach expiry.
Also please make sure you're on the latest version (2.6.1) as there were further improvements to passive and on-demand refreshing in the latest release 🙂Hi Ninzamax,
I just wanted to check if you were able to solve this by adding the middleware or is there something we can do to help?