Last Updated: February 25, 2016
·
1.016K
· reaktivo

Get client IP from Amazon's EC2 or Heroku on ExpressJS

getClientIp = (req) ->
  forwardedFor = req.header 'x-forwarded-for'
  if forwardedFor
    forwardedFor.split(',').shift()
  else
    req.connection.remoteAddress