Skip to content

Commit

Permalink
add optional proxy config property
Browse files Browse the repository at this point in the history
This is passed through to axios to allow the full range of proxy config and override capability.

By default axios looks at environment variables http_proxy and https_proxy to determine if proxy should be used. If these are not set then it will default off.

To force axios to not use the env variables, use `proxy: false`

To force different proxy values (overriding env variables) provide an object compatible with axios like

```js
proxy: {
  host: '127.0.0.1',
    port: 9000,
    auth: {
      username: 'mikeymike',
      password: 'rapunz3l'
    }
}
```

See https://github.com/axios/axios#config-defaults for full details about what is allowed by axios.
  • Loading branch information
jeffbski committed Jul 9, 2020
1 parent 4e58a26 commit 9fc72a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ var opts = {
/* strings or binaries */
],
passphrase: 'yourpassphrase',
proxy: false /* OR proxy config as defined in axios.
If not set axios detects proxy from env vars http_proxy and https_proxy
https://github.com/axios/axios#config-defaults
{
host: '127.0.0.1',
port: 9000,
auth: {
username: 'mikeymike',
password: 'rapunz3l'
}
} */,
auth: {
user: 'theuser', // or username
pass: 'thepassword', // or password
Expand Down
6 changes: 3 additions & 3 deletions lib/wait-on.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ const WAIT_ON_SCHEMA = Joi.object({
cert: [Joi.string(), Joi.binary()],
key: [Joi.string(), Joi.binary(), Joi.object()],
passphrase: Joi.string(),
proxy: [Joi.boolean(), Joi.object()],
auth: Joi.object({
username: Joi.string(),
password: Joi.string(),
}),
strictSSL: Joi.boolean().default(false),
ignoreProxy: Joi.boolean().default(false),
followRedirect: Joi.boolean().default(true), // HTTP 3XX responses
headers: Joi.object(),
});
Expand Down Expand Up @@ -265,10 +265,10 @@ function createHTTP$({ validatedOpts, output }, resource) {
followRedirect,
httpTimeout: timeout,
interval,
proxy,
reverse,
simultaneous,
strictSSL: rejectUnauthorized,
ignoreProxy,
} = validatedOpts;
const method = HTTP_GET_RE.test(resource) ? 'get' : 'head';
const url = resource.replace('-get:', ':');
Expand All @@ -284,9 +284,9 @@ function createHTTP$({ validatedOpts, output }, resource) {
...pick(['ca', 'cert', 'key', 'passphrase'], validatedOpts),
}),
...(followRedirect ? {} : { maxRedirects: 0 }), // defaults to 5 (enabled)
...(proxy && { proxy }),
...(timeout && { timeout }),
...urlSocketOptions,
...(ignoreProxy ? { proxy: false }: {}), // axios no proxy
method,
// by default it provides full response object
// validStatus is 2xx unless followRedirect is true (default)
Expand Down

0 comments on commit 9fc72a2

Please sign in to comment.