From ac1e9536e30e3b75461903407e7b885b4473b7dc Mon Sep 17 00:00:00 2001 From: Troplo Date: Sat, 30 Jul 2022 19:11:13 +1000 Subject: [PATCH] Update user.js --- backend/routes/user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/routes/user.js b/backend/routes/user.js index 80a0e10..8d9e461 100644 --- a/backend/routes/user.js +++ b/backend/routes/user.js @@ -61,7 +61,7 @@ router.post("/login", async (req, res, next) => { const ua = UAParser(req.headers["user-agent"]) let ip = {} await axios - .get("http://ip-api.com/json/ " + req.header("x-real-ip") || req.ip) + .get("http://ip-api.com/json/ " + req.ip) .then((res) => { ip = res.data }) @@ -71,7 +71,7 @@ router.post("/login", async (req, res, next) => { session: "COLUBRINA-" + cryptoRandomString({ length: 128 }), expiredAt: new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 30), other: { - ip: req.header("x-real-ip") || req.ip, + ip: req.ip, location: ip.country ? `${ip.city} - ${ip.regionName} - ${ip.country}` : null, @@ -150,7 +150,7 @@ router.post("/register", async (req, res, next) => { const ua = UAParser(req.headers["user-agent"]) let ip = {} await axios - .get("http://ip-api.com/json/ " + req.header("x-real-ip") || req.ip) + .get("http://ip-api.com/json/ " + req.ip) .then((res) => { ip = res.data }) @@ -160,7 +160,7 @@ router.post("/register", async (req, res, next) => { session: "COLUBRINA-" + cryptoRandomString({ length: 128 }), expiredAt: new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 30), other: { - ip: req.header("x-real-ip") || req.ip, + ip: req.ip, location: ip.country ? `${ip.city} - ${ip.regionName} - ${ip.country}` : null,