I am working on an express server, that used as an API for 3 web apps (admin, clients, and miniAdmin).
The project is in staging for testing before production, but the problem is that the cookies not saving on safari on macs, and all the browsers on IOS and IpadOS.
app.use(session({
name: `sid-${nconf.get('ServerConfig:projectName')}`, // The name of the session ID cookie
cookie: {
secure: process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'localhost', // If true, requires HTTPS
httpOnly: process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'localhost',
sameSite: process.env.NODE_ENV !== 'development' && process.env.NODE_ENV !== 'localhost' ? 'none' : 'strict'
},
secret: ****, // Signs the cookie - changing this will invalidate all existing cookies.
resave: false, // Forces the session to be saved back to the session store no matter what - We don't want this unless the session has changed.
saveUninitialized: false, // Sessions will only be created when user logs in when the value is false
store: MongoStore.create({
clientPromise: Promise.resolve(mongoose.connection.getClient()),
autoRemove: 'native', // Removes expired sessions
stringify: false // Prevents stringification of the session data
})
}));
Please help. thanks :)