Skip to content

Axios proxy as URL #37

Open
Open

Description

@jaunusa

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 :(

Activity

  1. jaunusa commented on Oct 12, 2023

    @jaunusa
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions