[Bug]: Session Expires in AdminJS with Node.js Clustering Using express-session
Contact Details
No response
What happened?
When using AdminJS in a Node.js application with the cluster module, logging into the AdminJS panel (/admin) is successful, but after login, its showing alert message "session expired" error and a redirection to /admin/login. This issue occurs only in a clustered environment and not when running a single process.
To Reproduce Set up a Node.js application with clustering, using @adminjs/express, express-session. Configure AdminJS with buildAuthenticatedRouter and a MongoDB database adapter. Start the server with multiple workers (e.g., node run.js). Access http://localhost:9090/admin, log in with valid credentials. Observe the "session expired" error and redirection to /admin/login.
Expected Behavior The session should persist across requests in all cluster workers, allowing uninterrupted access to AdminJS resources after login.
Actual Behavior After a successful login, navigating to resources or refreshing the page triggers a "session expired" error and a 302 redirect to /admin/login.
Environment Node.js version: v24 AdminJS version: [email protected] Database adapter: Mongodb/mongoose Environment: Production (NODE_ENV=production)
Bug prevalence
every time with cluster
AdminJS dependencies version
"@adminjs/bundler": "^3.0.0",
"@adminjs/express": "^6.1.1",
"@adminjs/mongoose": "^4.1.0",
"@sendgrid/mail": "^8.1.5",
"adminjs": "^7.8.16",
What browsers do you see the problem on?
No response
Relevant log output
Relevant code that's giving you issues
You use express-session but do you use a session store? Otherwise the session is saved in the memory and it's expected behaviour