fix(analytics): properly forward client IPs to Rybbit and OpenPanel

- Create new API route /api/rybbit/track to proxy Rybbit tracking requests
- Extract real client IP from Cloudflare headers (cf-connecting-ip)
- Forward X-Forwarded-For and X-Real-IP headers to analytics backends
- Update OpenPanel proxy to also forward client IP
- Update next.config.ts rewrite to use internal API route

This fixes geo-location issues where all traffic appeared to come from
Cloudflare edge locations instead of actual visitor countries.
This commit is contained in:
Unchained
2026-04-01 07:42:34 +02:00
parent 3c9c091c46
commit a3873bb50d
3 changed files with 78 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ const nextConfig: NextConfig = {
},
{
source: "/api/track",
destination: `${rybbitHost}/api/track`,
destination: "/api/rybbit/track",
},
{
source: "/api/site/tracking-config/:id",