This topic describes how to configure an endpoint in Alibaba Cloud SDK V1.0 for Node.js.
To configure an endpoint in Alibaba Cloud SDK V1.0 for Node.js, you can only specify a custom endpoint when you initialize the SDK client. When you specify a custom endpoint, you must add an http://
or https://
prefix to the endpoint. Example: https://ecs.cn-beijing.aliyuncs.com
.
Note
To ensure security, we recommend that you use https
.
The following sample code shows how to configure an endpoint in the remote procedure call (RPC) client:
const RPCClient = require('@alicloud/pop-core').RPCClient;
const client = new RPCClient({
// Obtain the AccessKey ID of the Resource Access Management (RAM) user from environment variables.
accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,
// Obtain the AccessKey secret of the RAM user from environment variables.
accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET,
endpoint: 'https://ecs.cn-beijing.aliyuncs.com', // https
// endpoint: 'http://ecs.cn-beijing.aliyuncs.com', // http
apiVersion: '2014-05-26',
});
The following sample code shows how to configure an endpoint in the resource-oriented architecture (ROA) client:
const ROAClient = require('@alicloud/pop-core').ROAClient;
const roaClient = new ROAClient({
// Obtain the AccessKey ID of the RAM user from environment variables.
accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,
// Obtain the AccessKey secret of the RAM user from environment variables.
accessKeySecret: process.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET,
endpoint: 'https://cs.cn-beijing.aliyuncs.com', // https
// endpoint: 'http://cs.cn-beijing.aliyuncs.com', //http
apiVersion: '2015-12-15',
});