Making a Req request with proxy

I haven’t tested but this should work:

Req.get!(
  url,
  connect_options: [proxy: {:http, "localhost", 22225, []}],
  proxy_headers: [{"proxy-authorization", "basic " <> Base.encode64("user:pass")}]
)

There is hardly any documentation for this in Req (Req — req v0.5.6) and very scarce in Mint (Mint.HTTP — Mint v1.6.2) so if you get this to work, a PR with docs improvements would be very appreciated. We have an open issue, Support http_proxy and https_proxy environment variables · Issue #394 · wojtekmach/req · GitHub, to support http_proxy and https_proxy env vars so that would probably be even better way to solve this.

5 Likes