Configuring proxies for Node.js - AWS SDK for JavaScript

Help us improve the AWS SDK for JavaScript version 3 (V3) documentation by providing feedback using the Feedback link, or create an issue or pull request on GitHub.

The AWS SDK for JavaScript V3 API Reference Guide describes in detail all the API operations for the AWS SDK for JavaScript version 3 (V3).

Configuring proxies for Node.js

If you can't directly connect to the internet, the SDK for JavaScript supports use of HTTP or HTTPS proxies through a third-party HTTP agent.

To find a third-party HTTP agent, search for "HTTP proxy" at npm.

To install a third-party HTTP agent proxy, enter the following at the command prompt, where PROXY is the name of the npm package.

npm install PROXY --save

To use a proxy in your application, use the httpAgent and httpsAgent property, as shown in the following example for a DynamoDB client.

const { NodeHttpHandler } = require("@aws-sdk/node-http-handler"); const proxyAgent = new ProxyAgent("http://internal.proxy.com"); const dynamodbClient = new DynamoDBClient({ requestHandler: new NodeHttpHandler({ httpAgent: proxyAgent, httpsAgent: proxyAgent }), });
Note

httpAgent is not the same as httpsAgent, and since most calls from the client will be to https, both should be set.