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.

Merge branch 'dev' of https://github.com/umami-software/umami into analytics

Francis Cao90682b79d202
diff --cc src/lib/detect.ts
index a023d27d2,0d3ca482b..2e6a067dd
--- a/src/lib/detect.ts
+++ b/src/lib/detect.ts
@@@ -124,10 -125,14 +125,14 @@@ export async function getLocation(ip: s
if (!global[MAXMIND]) {
const dir = path.join(process.cwd(), 'geo');
- global[MAXMIND] = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));
+ global[MAXMIND] = await maxmind.open(
+ process.env.GEOLITE_DB_PATH || path.resolve(dir, 'GeoLite2-City.mmdb'),
+ );
}
- const result = global[MAXMIND].get(ip);
+ // When the client IP is extracted from headers, sometimes the value includes a port
+ const cleanIp = ip?.split(':')[0];
- const result = global[MAXMIND].get(cleanIp);
++ const result = global[MAXMIND].get(cleanIp);
if (result) {
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;