Workers: Can't detect IPv6 only IPv4

This post was flagged by the community and is temporarily hidden.

Maybe it would work using full “expanded” like - just guessing?:
1111:2222:0006:010D:0000:0000:0000:9999

Moreover, how about using Cf-Connecting-IPv6 header instead of Cf-Connecting-IP which works for IPv4?
If that one actually exists, could be I am wrong due to Cf-Connecting-IP and X-Forwarded-For headers being overwrited?

Have you got IPv6 Compatibility option enabled at Cloudflare dashboard?

Thank you @fritexvz

Actually, cf-connecting-ip does give IPv6. What I’ve since found is I can’t actually check more than one IP address it breaks down.

if (request.headers.get(“cf-connecting-ip”) !== “1111:2222:6:10d::9999” ) <=== works fine

Trying to get it to OR check multiple IP’s doesn’t work, just breaks the worker. That was masking the issue with why I thought IPv6 was broken.

I’ve asked for this post to be deleted, as it’s incorrect now, but thank you for taking the time to reply :blush:

1 Like

@PFC Thank you too for explaining to me the situation and solution for the issue :wink: