I'm trying to find out in my ExpressJS app if the request comes from the localhost by using req.ip, however, it seems like the the value is different for different OSs. On my Ubuntu machine req.ip results in ::ffff:127.0.0.1, on a Mac though, it results in ::1 when I call the website via localhost. Is there anyway how to determine whether the request comes from localhost on all OSs?
I think, you can use this module: https://www.npmjs.com/package/request-ip.
Also, I found gist: https://gist.github.com/qiao/1626318