ip property

String get ip

Gets client IP address (handles proxies).

Implementation

String get ip {
  // Check for forwarded IP from proxy
  final forwarded = _raw.headers.value('x-forwarded-for');
  if (forwarded != null && forwarded.isNotEmpty) {
    return forwarded.split(',').first.trim();
  }

  // Check for real IP
  final realIp = _raw.headers.value('x-real-ip');
  if (realIp != null && realIp.isNotEmpty) {
    return realIp;
  }

  return _raw.connectionInfo?.remoteAddress.address ?? 'unknown';
}