Not getting remote address while using proxy in socket.io

后端 未结 3 1034
余生分开走
余生分开走 2020-12-28 09:18

In my socket.io code,

socket.sockets.on(\'connection\', function(client){ 
    var ip = client.handshake.address.address;
    ..
}

ip alwa

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-28 09:47

    yes, this is working for me.

    client.handshake.headers['x-forwarded-for'] || client.handshake.address.address;
    

    I am properly getting the remote IP address and not 127.0.0.1

提交回复
热议问题