Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: cloudflare intergration not working properly

Blue Mouse5d13880be026
diff --git a/backend/apps/selfhosted/src/common/utils.ts b/backend/apps/selfhosted/src/common/utils.ts
index 337813625..7f2881ef1 100644
--- a/backend/apps/selfhosted/src/common/utils.ts
+++ b/backend/apps/selfhosted/src/common/utils.ts
@@ -706,8 +706,16 @@ const getGeoDetails = (
// TODO: Add support for DBIP for self-hosted
// Stage 2: If Cloudflare is enabled, use their headers
- if (isProxiedByCloudflare && headers?.['cf-ipcountry'] !== 'XX') {
- return headers['cf-ipcountry'] || null
+ if (
+ isProxiedByCloudflare &&
+ headers['cf-ipcountry'] &&
+ headers?.['cf-ipcountry'] !== 'XX'
+ ) {
+ return {
+ country: headers['cf-ipcountry'],
+ city: null,
+ region: null,
+ }
}
// Stage 3: Using timezone based geo lookup as a fallback