Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Change env variable to CLIENT_IP_HEADER.

Mike Caob6ab8c381f08
diff --git a/lib/request.js b/lib/request.js
index 4f8fa8a7c..725dc3839 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -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'];