I’ve noticed that every time I save a file in Node.js it restarts the server and then I get logged out of my site and have to log back in again. Is this normal and is there any way to prevent it?
Enable Redis in your project settings, sessions will be persisted then
Hmmm - I did that but it stopped my site from working. Ran npm audit and got this…
I removed redis and now my site loads but the security doesn’t work at all.
Just to confirm @Apple…redis is the solution for persisting sessions, but I know that threw a wrench into the mix.
Have a look at your server settings panel as that is where you enable redis or memory for session management…maybe something was lost with the in/out of redis.
Your could also look at changing the redis version in your package.json to get past the bug.
The redis version in package.json is 3.1.2 so shouldn’t be affected.
I’ve tried uninstalling/reinstalling redis a few times (via the server settings panel) yet the issue persists.
Hmmm sorry, I’m all docker at this point and on a Mac, so I’m out of ideas.
Thanks for trying!
Enabling Redis shouldn’t have caused such a disaster
Can you enable Redis again and click the Deploy button?
It’s all a mystery to me!
I did manage to at least get it back to working without Redis. I hadn’t ticked the Delete Remore Files in the publisher. Once I did that it was back to working as before.
Is Redis the only way to have persistent sessions?
Have you checked redis logs?
On another approach, have you enabled “remember” for the login cookie.
I experienced this for a while and it drove me crazy.
I then noticed I had forgotten to set the remember login cookie. Once I enabled that I was auto logged back in after each server restart.
What’s the error on server start when you have redis enabled?
I can confirm similar behaviour for my production target - if I upload just one single file (API action or page) - session is reset. I don’t use Redis. NodeJS 16 - Debian 11.
It’s an expected behaviour as you are storing sessions in memory(RAM).
You need a persistent store(redis, database, file). Wappler uses redis for that.
You don’t need Redis or docker.
Just select DB as option in the server connect settings > sessions tab.
Server connect settings is in the server action/api panel top right.
This will create a table in your DB, named sessions
where sessions are stored and prevents logout on Node server restart.
Thanks sid. The database option seems to be working.
Thank you!
Works like a charm!