CF-Connecting-IP returns NULL in latest version of Workers?


#1

Hi folks,

a couple of weeks ago I developed a small script to test how Workers performs, but today I tested the live service and it seems the CF-Connecting-IP header always returns null, and before it returned the IP of the remote client. I have also tested it in the old Cloudflare Workers sandbox and I get the same error: it returns null and not the IP address.

Here goes the gist: https://gist.github.com/diegoparrilla/d7996da7fecb0491c179c150009f565e

Did I miss something? Is this still the right way to get the IP address of the remote client?

Cheers


#2

Hi Diego,

Hmm, I just tested this now, and it seems to work for me, both in production and in the preview. (By the way, we update the preview every week along with the Workers runtime, so it isn’t “old”. :slight_smile: )

Here’s a site implemented as a Worker that returns the headers it sees: http://canhazip.com/more

I see cf-connecting-ip showing my IP address, tested from multiple locations.

What do you see?


#3

Hi Kenton!

Ok, I found out what was going on: the worker gets the IP from cf-connecting-ip if I use the Preview mode. But I tried the Testing mode and then cf-connecting-ip has null. Obviously, it was my mistake because I did not get the difference between both modes. :crazy_face:

Thank you very much for your support. I really love this product!

Diego

P.D.: ‘Old’ because you have a shiny and awesome new product available to everyone. :heart_eyes:


#4

Ah, yes. In “Testing” mode, the idea is you can supply your own cf-connecting-ip value, so that you can test what happens if the IP isn’t your own. But I get how that’s not totally clear. We should probably automatically initialize all the usual headers in the request editor, and then let you modify from there.