Skip to content

Commit 7fd5577

Browse files
authored
fix(core): share request config across all requests (watson-developer-cloud#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
1 parent 1a751dd commit 7fd5577

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)
@@ -266,18 +267,6 @@ discovery.listEnvironments((err, res) => {
266267
});
267268
```
268269

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

283272
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.
@@ -352,6 +341,24 @@ var myInstance = new watson.WhateverServiceV1({
352341
});
353342
```
354343
344+
### Using the SDK behind a corporate proxy
345+
346+
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:
347+
```js
348+
const tunnel = require('tunnel');
349+
const AssistantV1 = require('ibm-watson/assistant/v1');
350+
351+
const assistant = new AssistantV1({
352+
iam_apikey: 'fakekey1234',
353+
version: '2019-02-28',
354+
httpsAgent: tunnel.httpsOverHttp({
355+
host: 'some.host.org',
356+
port: 1234,
357+
}),
358+
proxy: false,
359+
});
360+
```
361+
355362
### Configuring the HTTP client
356363
357364
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)