我有一个节点 js 服务器。我有获取请求 IP 的功能:
var ip = request.headers['x-forwarded-for'] ||
request.connection.remoteAddress ||
request.socket.remoteAddress ||
request.connection.socket.remoteAddress;
ip = ip.split(',')[0];
ip = ip.split(':').slice(-1);
return ip;
}```
But when I console.log(getCallerIP(request));
That send me sometimes in log : [ 'MYIP' ] and sometimes nothing.
Why ? And how to fix that ? ( in the server or the client )