Change env variable to CLIENT_IP_HEADER.

This commit is contained in:
Mike Cao 2021-11-21 09:39:22 -08:00
parent b1ced5f32c
commit b6ab8c381f

View File

@ -15,8 +15,12 @@ import {
let lookup;
export function getIpAddress(req) {
// Custom header
if (req.headers[process.env.CLIENT_IP_HEADER]) {
return req.headers[process.env.CLIENT_IP_HEADER];
}
// Cloudflare
if (req.headers['cf-connecting-ip']) {
else if (req.headers['cf-connecting-ip']) {
return req.headers['cf-connecting-ip'];
}
@ -52,11 +56,6 @@ export function getDevice(screen, browser, os) {
}
export async function getCountry(req, ip) {
// Custom header
if (req.headers[process.env.COUNTRY_IP_HEADER]) {
return req.headers[process.env.COUNTRY_IP_HEADER];
}
// Cloudflare
if (req.headers['cf-ipcountry']) {
return req.headers['cf-ipcountry'];