Hello,
Whenever I try to log in with the correct username and password on the Next.js front end (localhost:3000), in my post request for /login I am supposed to add two properties (.isAuth, and ._id) to my req.session on my Express.js back end (localhost:8080).
At first, these two things seem to be set, at least in /login. If the /login post request returns a 201 status code, the user is supposed to get redirected to the home page, and be able to see their data. However, when I get redirected to my home page, I cannot get any user data from the /user get request because req.session._id and req.session.isAuth don’t exist anymore.
When I check my MongoDB session store, the cookies do get stored every time a user logs in and do disappear after expiration, but the info I wanted to store on the ‘session’ part was not there. When I try to look for any cookies on Chrome Developer Tools, I don’t see any.
Setting secure to true, and sameSite to none does nothing. Including credentials in headers, cors middleware, and frontend requests did not do anything. When I look at the secure connection icon when viewing the website on localhost:3000, I get the “Your connection to this site is not secure” warning. I am on iOS, and am using Chrome to look at my website. I’ve tried Safari but it gives me the same problem.
So far I haven’t found a solution that has fixed my problem yet. I have looked at similar past issues on stackoverflow, on the open and closed issues on both express-session and connect-mongo, but nothing really helped so far. I am not sure if this is an express-session issue or a connect-mongo issue, so I think I will also post this issue on connect-mongo’s Issues section as well, in case if they find anything.
Here is the repository with all my current code surrounding this issue.
If you would like to ask me about further details that I didn’t mention that might contribute to this issue, or ask for clarification on anything I didn’t explain that well, please don’t hesitate!
Thank you all for your time and patience, it is much appreciated!