proxy-agent not working on Deno Deploy
I'm trying to use a proxy for the node-fetch requests in a deno app.
I chose proxy-agent npm package and its working great on my local. It reads HTTP_PROXY environment variable and uses that host as the proxy.
But when I deploy my app in Deno Deploy, proxy is not working. I set the environment variable correctly but proxy-agent is just ignoring that?
I appreciate any help.
6 Replies
Based on the documentation, Deno Deploy does not currently support all npm packages. While Deno Deploy does support importing built-in Node.js modules, it does not support all npm packages. The
proxy-agent
package you're trying to use is not a built-in Node.js module, so it might not be supported in Deno Deploy.
Deno Deploy does support proxies for module downloads and the Web standard fetch
API. Proxy configuration is read from environmental variables: HTTP_PROXY
, HTTPS_PROXY
and NO_PROXY
. However, this is different from using a proxy within your application logic, which seems to be what you're trying to do with proxy-agent
.
If you're trying to create a proxy server, the documentation provides an example of how to create a basic HTTP proxy server using the fetch
API:
In this example, all requests are proxied to https://example.com
.
If you're trying to use a proxy for outgoing requests from your application, you might need to use a different approach, as proxy-agent
might not be supported in Deno Deploy. Unfortunately, the documentation does not provide a clear answer on how to do this. 🦕But proxy-agent is working on my local, so deno supports it. But apparently Deno Deploy doesn't? Isn't it weird that Deno supports it but Deno Deploy service doesn't? Are we sure this is the problem here?
Hi, did you find a way to make it work?
sadly no
it just doesnt work when published but works in local
For me too, even createHttpClient doesnt work because its unstable api and i cant find any other way to make it work... i guess the only way is to self host the sever
yeah that seems like it