I have a curious situation with my NodeJS server: it seems like searching for the website on Google signs out the user.
The homepage is https://emocoes.org/pt/inicio
. I sign in to the website and the homepage shows the version for users, such as a "Content list" button.
I open a new tab, search for the website on Google and click the link. Now the homepage no longer shows the version for users. It's as if I had signed out. When I refresh the first tab with the member version of the homepage, it also shows the public version. I checked that the cookie for session in the session store still exists.
The URL from the Google query is:
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwjC2J3D65H4AhX5Q_EDHRpnCvoQFnoECAYQAQ&url=https%3A%2F%2Femocoes.org%2Fpt%2Finicio&usg=AOvVaw15-Ef1H79pA6DxaHMLJfgC
I do not see any issue in this link.
I added this tracing to the server's route for the homepage:
router.get("/pt/inicio", async (req, res) => {
console.log("URL = %o", req.originalUrl);
console.log("query = %o", req.query);
console.log("User = %o", req.user);
// The result after the Google URL is:
//[2022-06-03T17:40:21.308Z] URL = '/pt/inicio'
//[2022-06-03T17:40:21.308Z] query = {}
//[2022-06-03T17:40:21.309Z] User = undefined
...
});
Since the session exists in the MongoDB store, it's as if clicking the Google link deletes the cookie in the browser. I have Safari on macOS but the same thing happens to another user on Windows and Google Chrome.
How can I debug this issue?