HTTP Server

Client IP Resolution

Highly robust API designed to identify the real client IP address across proxies, load balancers, and VPNs.

Resolution Order

To ensure maximum accuracy, getIp checks headers in a specific order of trustworthiness, supporting Cloudflare, Akamai, Nginx, and more.

1. CF-Connecting-IP (Cloudflare)
2. True-Client-IP (Akamai)
3. X-Real-IP (Nginx)
4. X-Forwarded-For (Standard)
5. Forwarded (RFC 7239)
6. Socket Remote Address

Usage Examples

Basic Resolution

typescript
import { getIp } from "xypriss";

app.get("/api/whoami", (req, res) => {
    const ip = getIp(req);
    res.json({ yourIp: ip });
});

Enriched Metadata

Retrieve the resolved IP along with the source header that provided it.

typescript
app.get("/api/debug-ip", (req, res) => {
    const { ip, source } = getIp(req, true);
    res.json({ ip, source });
});

Security Protections

  • 1

    Public IP Filtering: Prioritizes public ranges over private (RFC 1918) to prevent header spoofing.

  • 2

    Normalization: Automatically strips port numbers and sanitizes IPv6-mapped IPv4 prefixes.

File Streaming

Learn about zero-copy native asset delivery via XHSC.