Hi,
I’d like to use a proxy with fetch, but since according to my reading that doesn’t appear to be possible, is it possible to use an alternate library like axios? I downloaded axios and tried it and the get just fails for no apparent reason.
thanks
Node APIs don’t work on Workers.
Axios use a lot of Node-native APIs so it will not work, I think you’d basically need to rewrite it to get it to work.
Use fetch instead:
Yes, But fetch doesn’t seem to support proxies so how can I use it?
Connecting to any proxy should work, however, you cannot connect directly to IP numbers - only domains.
I’m sorry, I don’t know what you mean. Do you mean with something like:
{agent: new HttpsProxyAgent(‘proxyHost:proxyPort’)})
Maybe I messed up, but that didn’t work for me.
HttpsProxyAgent also rely on Node API’s and WebSockets, which CF Workers also don’t support.
Workers aren’t meant to hold connections open for long durations, so if you need WebSockets, you’ll have to use Node.
Thanks for the explanation, but proxies aren’t just for websockets, it’s kind of a normal thing to need to do.
That’s true and Cloudflare normally passes WebSockets through to the origin, but since Workers still don’t support it, it cannot be used. I’m also waiting for it to arrive (Together with many other thing).
Many things aren’t possible to build until they add more CPU-time either.