read cf requestee IP from the headers first

This commit is contained in:
Holly Stubbs 2021-09-03 21:13:17 +01:00
parent 3e9491e9de
commit b955d19811

View file

@ -25,7 +25,14 @@ module.exports = async function(req, res, loginInfo) {
}
// Get users IP for getting location
let requestIP = req.get('X-Real-IP');
// Get cloudflare requestee IP first
let requestIP = req.get("cf-connecting-ip");
// Get IP of requestee since we are probably behind a reverse proxy
if (requestIP == null)
requestIP = req.get("X-Real-IP");
// Just get the requestee IP (we are not behind a reverse proxy)
if (requestIP == null)
requestIP = req.remote_addr;