From fd2e2047cdf400da1deccec062a570ed1540b4d5 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 23 Jan 2026 20:30:42 -0800 Subject: [PATCH] Restrict x-umami-client-* headers to cloud mode only. --- src/lib/detect.ts | 16 ++++++++++------ src/lib/ip.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lib/detect.ts b/src/lib/detect.ts index 6af61b78..e713ecf7 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 b4c46573..f6ee733b 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