Skip to content

Commit 17ba3b3

Browse files
committed
fix(core): share request config across all requests (#928)
* fix added by bumping core to 0.3.5 * this will allow users to configure all requests, which fixes a bug that prevented use of the SDK behind a corporate proxy * documentation added for this use case in the readme (cherry picked from commit 7fd5577)
1 parent cb2d89f commit 17ba3b3

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Node.js client library to use the Watson APIs.
2424
* [Sending request headers](#sending-request-headers)
2525
* [Parsing HTTP response](#parsing-http-response)
2626
* [Data collection opt-out](#data-collection-opt-out)
27+
* [Using the SDK behind a corporate proxy](#using-the-sdk-behind-a-corporate-proxy)
2728
* [Documentation](#documentation)
2829
* [Questions](#questions)
2930
* [IBM Watson services](#ibm-watson-services)
@@ -269,18 +270,6 @@ discovery.listEnvironments((err, res) => {
269270
});
270271
```
271272

272-
### Setting the service URL
273-
274-
You can set the service URL by calling the setServiceUrl() method.
275-
276-
```javascript
277-
const discovery = new DiscoveryV1({
278-
version: '<version-date>'
279-
});
280-
281-
discovery.setServiceUrl('https://gateway-wdc.watsonplatform.net/discovery/api');
282-
```
283-
284273
### Sending request headers
285274

286275
Custom headers can be passed with any request. Each method has an optional parameter `headers` which can be used to pass in these custom headers, which can override headers that we use as parameters.
@@ -355,6 +344,24 @@ var myInstance = new watson.WhateverServiceV1({
355344
});
356345
```
357346
347+
### Using the SDK behind a corporate proxy
348+
349+
To use the SDK (which makes HTTPS requests) behind an HTTP proxy, a special tunneling agent must be used. Use the package [`tunnel`](https://github.com/koichik/node-tunnel/) for this. Configure this agent with your proxy information, and pass it in as the HTTPS agent in the service constructor. Additionally, you must set `proxy` to `false` in the service constructor. See this example configuration:
350+
```js
351+
const tunnel = require('tunnel');
352+
const AssistantV1 = require('ibm-watson/assistant/v1');
353+
354+
const assistant = new AssistantV1({
355+
iam_apikey: 'fakekey1234',
356+
version: '2019-02-28',
357+
httpsAgent: tunnel.httpsOverHttp({
358+
host: 'some.host.org',
359+
port: 1234,
360+
}),
361+
proxy: false,
362+
});
363+
```
364+
358365
### Configuring the HTTP client
359366
360367
The HTTP client can be configured to disable SSL verification. Note that this has serious security implications - only do this if you really mean to! ⚠️

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"axios": "^0.18.0",
8787
"dotenv": "^6.2.0",
8888
"extend": "~3.0.2",
89-
"ibm-cloud-sdk-core": "^0.3.4",
89+
"ibm-cloud-sdk-core": "^0.3.5",
9090
"isstream": "~0.1.2",
9191
"object.pick": "~1.3.0",
9292
"snyk": "^1.192.4",

0 commit comments

Comments
 (0)