The Arcjet IP detection library provides a utility to find the public IP of a
Request.
What are Arcjet utilities?
Arcjet utilities are independent libraries
that do not require the use of the main Arcjet SDK—they can be used with or
without other Arcjet rules.
We take the pain out of implementing security tasks through these utilities
to provide a security as code approach to developer-first security.
Why
The public IP of a Request is difficult to discern, but some platforms provide
specific mechanisms for accessing it—such as the X-Real-IP header added or
overwritten by Vercel. The @arcjet/ip library provides a streamlined API over
these mechanisms based on the current platform.
Install
Usage
Platform protections
Additional guards can be applied with the platform option, such as
{ platform: "fly-io" }, { platform: "cloudflare" }, or
{ platform: "vercel" }.
Proxy filtering
Most proxies will add themselves in the chain of public IP addresses. Trusted
proxies may be specified with the proxies option, and they will be
ignored when detecting a public IP.
API
ip(request: RequestLike, options?: Options)
Look up an IP address in a Request-like object, such as Request, Node’s
http.IncomingMessage, or Next.js’ NextRequest.