(options: ProxyOptions): MiddlewareHandler import {create_proxy_middleware} from '@fuzdev/fuz_app/http/proxy.js'; Create a Hono middleware that resolves the client IP from trusted proxies.
Sets client_ip on the Hono context for downstream use by get_client_ip.
All client IPs are normalized (lowercase, IPv4-mapped IPv6 stripped).
Resolution logic:
- No
X-Forwarded-For→ use connection IP directly. X-Forwarded-Forpresent but connection is untrusted → ignore header (spoofed by a direct attacker), use connection IP.X-Forwarded-Forpresent and connection is trusted → walk header right-to-left, strip trusted entries, use first untrusted entry; a malformed entry stops the walk and the connection IP is used.
options
trusted proxy configuration
returns
MiddlewareHandler throws
Error- if any entry in `options.trusted_proxies` is invalid (parsed eagerly via `parse_proxy_entry`)
mutates
c.var.client_ip— set to the resolved (or `'unknown'`) client IP per request