Daylogs/Javascript
노드에서 사용자 IP 가져오기
ohgyun
2014. 11. 21. 00:18
발생일: 2014.11.20
키워드: node, express, ip
문제:
node 로 작성한 http 서버에서 사용자의 IP를 가져오고 싶다.
어떻게 가져오면 될까~
해결책:
요청이 프록시를 타고 오는 경우도 가정해, 아래 코드를 사용하면 된다~
req.connection.remoteAddress ||
req.socket.remoteAddress ||
req.connection.socket.remoteAddress;
반응형