Checklist
Description
On my site with dozens of components I noticed that sometimes when a user tries to logout, the user is redirected through the logout process, but finally is still logged in. This seemed to happen mostly when trying to logout while parts of the site are still loading,
I analyzed this in the browser network tab and noticed that the reason are requests that are still in-flight while the user presses the logout button.
While the /auth/logout request correctly clears the session cookies, the in-flight requests sometimes get responses after /auth/logout and set the session back to active.
Timeline:

A walkaround for me was to use the auth0/nextjs-auth0 middleware only on /auth paths, contrary to what is recommended in the documentation:
if (path.startsWith("/auth/")) { // added this condition
const authResponse = await auth0.middleware(request);
// other auth code
}
// other site specific middleware
Obviously, this prevents rolling sessions from working.
Reproduction
Logging out while there are ongoing requests.
Additional context
No response
nextjs-auth0 version
4.9.0
Next.js version
15.5.2
Node.js version
20.19.2
Checklist
Description
On my site with dozens of components I noticed that sometimes when a user tries to logout, the user is redirected through the logout process, but finally is still logged in. This seemed to happen mostly when trying to logout while parts of the site are still loading,
I analyzed this in the browser network tab and noticed that the reason are requests that are still in-flight while the user presses the logout button.
While the
/auth/logoutrequest correctly clears the session cookies, the in-flight requests sometimes get responses after/auth/logoutand set the session back to active.Timeline:

A walkaround for me was to use the auth0/nextjs-auth0 middleware only on
/authpaths, contrary to what is recommended in the documentation:Obviously, this prevents rolling sessions from working.
Reproduction
Logging out while there are ongoing requests.
Additional context
No response
nextjs-auth0 version
4.9.0
Next.js version
15.5.2
Node.js version
20.19.2