Skip to content

Instantly share code, notes, and snippets.

@ashleighbasil
Created March 22, 2021 04:16
Show Gist options
  • Save ashleighbasil/239ed497769c5eb88574edeb14629e75 to your computer and use it in GitHub Desktop.
Save ashleighbasil/239ed497769c5eb88574edeb14629e75 to your computer and use it in GitHub Desktop.
log ips
const express = require('express')
var cors = require('cors')
const PORT = process.env.PORT || 5000
const viewLog = []
express()
.use(cors())
.get('/ping', (req, res) => {
const ip = req.headers['x-forwarded-for']
if (!viewLog.includes(ip)) {
viewLog.push(ip)
}
res.send(JSON.stringify(viewLog))
})
.listen(PORT, () => console.log(`Listening on ${ PORT }`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment