web-ip-extract Edge Function — Web Search
Web SearchExtract the real client IP address from HTTP request headers, with proxy trust control and private IP detection.
Edge function web-ip-extract Extract the real client IP address from HTTP request headers, with proxy trust control and private IP detection.. Deployed on Cloudflare Workers — zero cold starts, globally distributed. Mount it via your Aerostack workspace to call it from any AI agent.
npx aerostack add navin/web-ip-extract Use with AI Assistants
MCPConnect Claude, Cursor, or any MCP-compatible client — then call this function by slug
① Add MCP Server
Add this once — access all Aerostack functions from your AI tool.
{
"mcpServers": {
"aerostack": {
"url": "https://mcp.aerostack.dev",
"type": "http"
}
}
} ② Call this function
Ask your AI to use the call_function tool with this slug:
call_function({
slug: "web-ip-extract",
args: {
"headers": null,
"options": null
}
}) web-ip-extract — Extract real client IP from headers
Reliably extract the true client IP from HTTP request headers, respecting Cloudflare, reverse proxies, and X-Forwarded-For chains with private IP detection.
API
POST /api/web-ip-extract
Request body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
headers |
object | Yes | — | HTTP request headers |
options.trustProxy |
boolean | No | true | Whether to trust proxy headers |
options.prefer |
'cf'|'forwarded'|'socket' |
No | 'cf' |
Header preference order |
Success response (200)
{
"success": true,
"data": {
"ip": "1.2.3.4",
"source": "cf-connecting-ip",
"allIps": ["1.2.3.4", "5.6.7.8"],
"isPrivate": false
}
}
Error responses
| Code | HTTP | When |
|---|---|---|
INVALID_INPUT |
400 | Invalid headers structure |
INTERNAL_ERROR |
500 | Unexpected error |
Usage
Direct import
import { webIpExtract } from '@aerostack/functions/web-ip-extract';
const result = webIpExtract({ headers: Object.fromEntries(request.headers) });
console.log(result.ip); // '1.2.3.4'
console.log(result.isPrivate); // false
Use Cases
- Rate limiting by real client IP behind Cloudflare or a load balancer
- Geo-IP lookups using the actual client address
- Blocking or logging requests from private/internal network IPs
Metadata
Tags
Publisher
@navin verified
Build and publish your own functions
Write a TypeScript function, deploy it to the edge, and share it with thousands of developers — in minutes.
More Web Search Functions
Browse Web Search Functions →web-query-stringify
by @navin
Serialize a parameters object to a URL query string with support for arrays, encoding, and null skipping.
web-content-type-parse
by @navin
Parse a Content-Type header value into MIME type, subtype, charset, boundary, and convenience boolean flags.
web-headers-parse
by @navin
Parse a raw HTTP header block string or object into a structured lowercase-keyed object with content-type and authorization extraction.
web-query-parse
by @navin
Parse a URL query string into a typed object with support for arrays, number/boolean coercion, and bracket notation.
web-url-build
by @navin
Build a URL from a base and optional path, query parameters, and hash fragment.
web-url-parse
by @navin
Parse a URL into structured parts including protocol, host, pathname, query object, and hash.
Frequently asked questions
What does the web-ip-extract function do? +
web-ip-extract is a serverless edge function for web-search automation written in aerostack. Deploy it to Cloudflare Workers via your Aerostack workspace.
How do I deploy the web-ip-extract function? +
Install the Aerostack CLI and run: ```bash aerostack deploy function @navin/web-ip-extract ``` It will be live on Cloudflare Workers in seconds.
What runtime does web-ip-extract use? +
web-ip-extract runs on aerostack on the Cloudflare Workers edge runtime — zero cold starts, globally distributed.
Can I customise the web-ip-extract function? +
Yes. Fork the function from your Aerostack dashboard, modify the source, and redeploy. All changes are version-controlled.