Worker keep same Ip

I am playing with workers however one task i am trying to do involves making 2 external requests and i notice that while both tasks happen in the same script, each request happens on a new ip address.

eg:

    const [btcResp, ethResp, ltcResp] = await Promise.all([
          fetch('https://api.ipify.org/?format=json', init),
          fetch('https://api.ipify.org/?format=json', init),
          fetch('https://api.ipify.org/?format=json', init)
        ])


 return new Response(btc.ip+' - '+eth.ip+' - '+ltc.ip, responseInit)

would result in:

141.101.104.208 - 141.101.76.199 - 141.101.104.247

Is there any way i can keep the same ip address at least for that session from a worker?

1 Like

Which worker that will run the script cannot be controlled, however, if you want to white-list Worker IP’s you can always find an up-to-date list of IP’s here: https://www.cloudflare.com/ips-v4

This is also a use case for me – I’m using an external API that generates a download link that is locked to the IP that requests the link. So I just need to do two back-to-back fetch() requests from the same IP. Note that the IP does not have to be consistent across invocations.