Client public IP API at the edge

Quickly fetch the user's public IP from an API endpoint on your own domain, with no origin.

VCL

Use this solution in your VCL service (click RUN below to test this solution or clone it to make changes):

Compute@Edge

Use this solution in your Compute@Edge service:

  1. Rust
let json = match req.get_client_ip_addr() {
Some(ip_addr) => json!({ "ClientIP": ip_addr }),
None => json!({ "ClientIP": null }),
};
Ok(Response::new().with_body_json(&json)?)