NodeJS autologin when page load

I make voteAPP and if the user IP is already in DB and I see most people do that as click on button sign.

First: is possible to obtain IP after page load to check in mongoDB?

Second I make and idea to /autologin route and redirect with JS when body load
window.location.href = "/autologin";
then route in NodeJS its checked and then redirect to “/”.
but that make infinite loop.

Do you think that save to session or something run once variable or there is a other trick?