Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axios proxy as URL #37

Open
jaunusa opened this issue Oct 11, 2023 · 1 comment
Open

Axios proxy as URL #37

jaunusa opened this issue Oct 11, 2023 · 1 comment

Comments

@jaunusa
Copy link

jaunusa commented Oct 11, 2023

The options parameter of the Translator constructor only takes one type of proxy as ProxyConfig (looks same as AxiosProxyConfig).
It would be useful to be able to use a proxy URL string as proxy parameter. An axios instance creation in the client should look like this:

import { HttpProxyAgent, HttpProxyAgent } from 'hpagent';
axios.create({
   proxy: true,
   httpsAgent: new HttpsProxyAgent({ proxy: 'http://user:pw@myproxy.com:4567' })
   httpAgent: new HttpProxyAgent({ proxy: 'http://user:pw@myproxy.com:4567' })
})

Would it be an improvement in flexibility?
I always use one secret for the whole proxy URL, so it would help a lot.

The most flexible approach would be to have an axiosInstanace parameter for the Translator constructor, but this would cause a lot of code rewrites :(

@jaunusa
Copy link
Author

jaunusa commented Oct 12, 2023

I did more tests to try to pass through a proxy with authentication using deepl-node package (version 1.10.2), without success. Always getting a Bad request with this proxy configuration:

host: 'proxy.myproxy.com',
port: 4567,
protocol: 'http',
auth: {
   username: myuser,
   password: mypw
}

I used a lot of packages with included axios and couldn't pass the proxy. The only working fix was to use my own axios instances, configured with the axios config from my first post. #37 (comment)

Simple cURL tests with proxy params work too, so it has to be some special axios implementation for this two types of config.

Is there a way to inject the working kind of config to the deepl-node axios instance?
Or is there an easy way to make this package take additional parameters for httpAgent and proxy (as bool)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant