You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auth0-nextjs works as follows on requests to Server Action when processed by middleware: auth-client.js
Retrieve the session from the sessionStore
If session can be retrieved, update sessionStore for rolling update
a. For the default StatelessSessionStore, encrypt the originalSessionData in the session into jwe, chunk it, and store it in the cookie. In jwe, the cookie is updated each time because it includes the time of creation: stateless-session-store.ts
b. For StatefulSessionStore, session ID is chunked into jwe and stored in cookie. jwe includes generation time, so cookie is updated every time stateful-session-store.ts
Reproduction
Assumption
In middleware, set up a call to auth0.middleware
Reproduce with or without sessionStore set in Auth0 configuration
Reproduction
Call Server Action
Because auth0.middleware performs authentication processing, a Set-Cookie is added to the response header, X-Action-Revalidated becomes [[],0,1], and NextJS Client follows the instructions to reload RSC (React Server Component) reloading the RSC (React Server Component) as instructed.
server-action-call-revalidates-by-set-cookie.mov
Additional context
When server action call, please skip to update cookie. We can identify server action when the request has Next-Action header.
Or if session.rolling is false, skip cookie update process and manage cookie lifetime based on the first cookie created. This TODO comment suggests this behavior
Checklist
Description
Auth0 middleware sets cookies and triggers page reloads on every Server Action call
Cause
a. For the default StatelessSessionStore, encrypt the originalSessionData in the session into jwe, chunk it, and store it in the cookie. In jwe, the cookie is updated each time because it includes the time of creation: stateless-session-store.ts
b. For StatefulSessionStore, session ID is chunked into jwe and stored in cookie. jwe includes generation time, so cookie is updated every time stateful-session-store.ts
Reproduction
Assumption
Reproduction
server-action-call-revalidates-by-set-cookie.mov
Additional context
When server action call, please skip to update cookie. We can identify server action when the request has
Next-Actionheader.Or if session.rolling is false, skip cookie update process and manage cookie lifetime based on the first cookie created. This TODO comment suggests this behavior
nextjs-auth0 version
4.6.0
Next.js version
15.3.2
Node.js version
22.10