Created
March 22, 2021 04:16
-
-
Save ashleighbasil/239ed497769c5eb88574edeb14629e75 to your computer and use it in GitHub Desktop.
log ips
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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