core icon indicating copy to clipboard operation
core copied to clipboard

Implement regular proxy

Open rbozan opened this issue 1 year ago • 2 comments

Hi, I'd like to use the pkg but I'd like to see the possibility to use a regular proxy as well, not just a CORS proxy.

https://axios-http.com/docs/req_config

This can be done under axios with the proxy field.

As a workaround for now, you can use:

import axios from 'axios';

axios.defaults.proxy =  {
    host: '127.0.0.1',
    port: 9000,
    auth: {
      username: 'mikeymike',
      password: 'rapunz3l'
    }
  }

for a default proxy (all your axios calls)

rbozan avatar May 14 '24 18:05 rbozan

Hi, current library is aimed to be unified and extendable, so we can't provide axios-specific features on level of current library, because it would bounds us to a implementation of fetcher.

But i see your concern, you need to use a proxy server like socks or https instead of CORS proxy.

To resolve this problem, we could introduce some option in Translator constructor, to provide a fetcher. If you use axios, you would create some fetcher class/function with configured proxy details, and then Translator will use provided fetcher implementation to sent requests.

In case you need to run code in browser, you still may provide a wrapped fetch.

What you think about it? Is it would fix your problem?

vitonsky avatar May 14 '24 22:05 vitonsky

That would also indeed fix the problem, and would allow me to customize the axios / fetch client further than just the proxy if needed.

rbozan avatar May 15 '24 04:05 rbozan