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.

Restrict x-umami-client-* headers to cloud mode only.

Mike Caofd2e2047cdf4
diff --git a/src/lib/detect.ts b/src/lib/detect.ts
index 6af61b78f..e713ecf71 100644
--- a/src/lib/detect.ts
+++ b/src/lib/detect.ts
@@ -10,12 +10,16 @@ import { safeDecodeURIComponent } from '@/lib/url';
const MAXMIND = 'maxmind';
const PROVIDER_HEADERS = [
- // Umami custom headers
- {
- countryHeader: 'x-umami-client-country',
- regionHeader: 'x-umami-client-region',
- cityHeader: 'x-umami-client-city',
- },
+ // Umami custom headers (cloud mode only)
+ ...(process.env.CLOUD_MODE
+ ? [
+ {
+ countryHeader: 'x-umami-client-country',
+ regionHeader: 'x-umami-client-region',
+ cityHeader: 'x-umami-client-city',
+ },
+ ]
+ : []),
// Cloudflare headers
{
countryHeader: 'cf-ipcountry',
diff --git a/src/lib/ip.ts b/src/lib/ip.ts
index b4c465736..f6ee733b9 100644
--- a/src/lib/ip.ts
+++ b/src/lib/ip.ts
@@ -1,5 +1,5 @@
export const IP_ADDRESS_HEADERS = [
- 'x-umami-client-ip', // Umami custom header
+ ...(process.env.CLOUD_MODE ? ['x-umami-client-ip'] : []), // Umami custom header (cloud mode only)
'true-client-ip', // CDN
'cf-connecting-ip', // Cloudflare
'fastly-client-ip', // Fastly