Skip to content

Instantly share code, notes, and snippets.

const parseIp = (req) =>
req.headers['x-forwarded-for']?.split(',').shift()
|| req.socket?.remoteAddress
console.log(parseIp(req))
// => 127.0.0.1
// example ^^
// this is not mine, I took it from stackoverflow