I am having an issue about cookies in my mern stack project I use passport local strategy for auth and express-session for session storage and database is deployed on mongodb atlas, actually everything works correctly on the laptop but in incognito mode once I login and go to any protected route it says not authenticated and no cookie is set in application tab and in mobile phone some account works properly like I am able to login and other other operation also but I am not able to login on some accounts, so this is my problem for code base this is public GitHub Repo : also my backend and frontend is deployed on Render and this is my setup : enter code here
app.set("trust proxy", true);
app.use(cookieParser());
const store = MongoStore.create({
mongoUrl: process.env.MONGO_URL,
crypto: { secret: process.env.SECRET_SESSION_KEY },
ttl: 24 * 3600,
});
const sessionMiddleware = session({
secret: process.env.SECRET_SESSION_KEY,
resave: false,
saveUninitialized: false,
store: store,
cookie: {
maxAge: 7 * 24 * 60 * 60 * 1000,
httpOnly: true,
secure: true,
sameSite: "none",
}
});
app.use(sessionMiddleware);
// Passport Setup
app.use(passport.initialize());
app.use(passport.session());
passport.use(new LocalStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());