fix: user location fix

This commit is contained in:
Krispire Admin
2026-06-18 23:52:17 +05:30
parent dc204577a8
commit d52530c52c
3 changed files with 54 additions and 4 deletions
+3 -3
View File
@@ -32,9 +32,9 @@ func CountryFromCloudflare(r *http.Request) string {
return cc
}
// ClientIP returns the best guess at the caller's IP. The chi RealIP
// middleware already rewrites r.RemoteAddr from X-Forwarded-For /
// X-Real-IP, so we just strip the port.
// ClientIP returns the best guess at the caller's IP. The middleware.RealIP
// middleware already rewrites r.RemoteAddr to the real client (right-most
// X-Forwarded-For entry from the trusted edge proxy), so we just strip any port.
func ClientIP(r *http.Request) string {
host, _, err := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr))
if err != nil {