I have a simple worker function attached to my static CF Pages that runs fetch(). I use the
request.headers.get("CF-Connecting-IP")
to get the IP of the original requestor and I then set the ‘X-Forwarded-For’ header to that IP address when I run fetch. However, when the request goes out, the header is:
X-Forwarded-For: User-Ip, Cloudflare-IP
Where the Cloudflare-IP is 2a06:98c0:3600::103 which is (I think) from CF-Pages gets added to the X-Forwarded. This seems like odd behavior. While technically I believe the path is
User -> CF Pages -> CF Function -> fetch
It seems this isn’t really a double proxy with two forwards as the CF Pages->CF Function should, I think, be transparent. In any case, is there a way to get a function in CF-Pages make a fetch with just the user’s IP in the X-Forwarded-For header? If I don’t manually add the X-Forwarded-For header to my fetch, CF sets the X-Forwarded-For header to just the Cloudflare-IP (which again, seems odd given the setup). I tried playing around with Transform Rules, but since the issue is the headers between two Cloudflare services (pages, workers), I didn’t see a way to get that to help.
Thanks,