Ayzal AIAYZAL .AI
← Back to Knowledge Base
integrations

Getting the Email and IP Correctly

How to reliably extract the end-user email and IP in every framework

Email

The email comes from your checkout/signup form. It is the same address the user types. Pass it in the JSON body as email.

IP — the correct one

You need the end user IP, not your server IP. If your app sits behind nginx, Cloudflare, AWS ALB, or any reverse proxy, the client IP is in the X-Forwarded-For header — specifically the leftmost value.

Per-framework

FrameworkCode
Flaskrequest.headers.get("X-Forwarded-For", "").split(",")[0].strip() or request.remote_addr
Express(req.headers["x-forwarded-for"] || "").split(",")[0].trim() || req.socket.remoteAddress
FastAPIrequest.headers.get("x-forwarded-for", "").split(",")[0] or request.client.host
PHP$_SERVER["HTTP_X_FORWARDED_FOR"] ?? $_SERVER["REMOTE_ADDR"]
Railsrequest.headers["X-Forwarded-For"]&.split(",")&.first || request.remote_ip

What NOT to do

Never send 127.0.0.1 or an internal IP. The Guard API treats private IPs as unknown and returns ip_risk: null — you lose the intelligence layer.