Proxy fetch requests from the edge

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.