Public
Express
Readme

I wanted to see if val.town forwards my client IP Address using the x-forwarded-for header, which it does, but cloudflare provides the True-Client-IP header as well. When you run a val on the website, it is actually running from val's servers so it won't come from your client IP. You'll need to copy the express fetch and run that from your client.

1
2
3
4
5
6
7
8
export let whatIsMyIp = (req: express.Request, res: express.Response) => {
const xForwardedFor = req.get("x-forwarded-for");
const ip = req.get("True-Client-IP");
res.json({
ip,
xForwardedFor,
});
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
nico-whatismyip.express.val.run
October 23, 2023