Last active
December 15, 2022 08:29
-
-
Save Shaxadhere/0e453488e9306057fac2678e47204009 to your computer and use it in GitHub Desktop.
get request information in express js server.
This file contains hidden or 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 { UAParser } = require("ua-parser-js") | |
const ipLocator = require('ip-locator') | |
const parser = new UAParser(req.headers['user-agent']); | |
const result = parser.getResult() | |
const ip = req.headers['x-forwarded-for'] || req.socket.remoteAddress | |
ipLocator.getDomainOrIPDetails(ip, "json", function (err, ipInfo) { | |
res.json({ result, ipInfo }) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment