I need to make fetch requests from an edge function, but i need programatic control at run time over using an http proxy. This works fine in the serverless functions where i can use node-fetch and https-proxy-agent, but I can’t seem to find any way to get fetch from Edge Functions / deno to use a proxy. The proxy must be set at run time for each request, it should not be set globally for the lifetime of the deno process.
Edge Functions support npm modules, so you can try using node-fetch there as well.
I got an automated message asking me to mark this as the solution, but it is not. I did try using node-fetch, along with some other fetch implementations, and while they did execute none of them were capable of proxying from an edge function. No matter what I did the traffic still came from the edge node and not from my proxy server.
FWIW I tried this with some other edge function implementations as well, including Supabase edge functions and direct with Deno Deploy, and it didn’t work there either. I discovered Deno.createHttpClient which when run locally on my laptop does proxy from Deno, however Deno Deploy does not expose unstable functions so I can’t even use that. I just have to wait for createHttpClient to become stable and eventually make it into the Netlify stack. I really do hope this happens…
For now, I setup a 24/7 traditional Node.js process running on a different provider that just relays requests I need to go through a proxy server, and I’m making direct http requests to that from my Netlify Edge Functions, and letting that service make the proxied requests.
I see the rollout of Deno 2.0 has begun. Is it possible to use Deno.createHttpClient in the Netlify build of Deno 2.0?
If so, how do I check if my sites have been upgraded yet, or how do I control it so they get upgraded?
Thanks!
I’m not sure about Deno.createHttpClient. You can try it out in the latest versions of Netlify CLI. It already uses Deno 2.
As of the sites, the execution environment is already upgraded to Deno 2 for a few months now, and we’re in the process of upgrading to Deno 2 in the build environment. We had done that but we ran into some issues, and the rollout is in progress as we speak. If all goes well, Deno 2 should be enabled in the build system as well by next week or so.
Following-up on this. I got a chance today to test this out. Deno.createHttpClient works fine in the Netlify CLI, but I get the “Deno.createHttpClient is not a function” error when trying to run in in production. I assume by now the Deno 2.x rollout is complete.
Deno.createHttpClient is marked as Stable for Deno 2.x. What is the right way to ask for Deno.createHttpClient to be supported in the Netlify edge run time? Should I open a ticket with support? For years now I’ve been forced to run a 24/7 service on another platform just to route requests from Netlify edge functions through said service that turns around and proxies them. I would really love to get rid of that extra service in my architecture.
Thank you!
I’m asking the devs for the latest status of this.
They confirmed that Deno.createHttpClient is supported and it’s also being used internally by our own code - so it’s definitely working. Could you share an example repo where it’s not working?
I had Claude put together a sample repo that demonstrates the problem. It is deployed to
Thank you, I’ve passed that back to the devs.