Configure an endpoint

更新时间:
复制 MD 格式

Alibaba Cloud SDK V1.0 for Node.js supports endpoint configuration only through a custom endpoint specified during client initialization.

You can specify a custom endpoint only when you initialize the SDK client. The endpoint must include an http:// or https:// prefix. Example: https://ecs.cn-beijing.aliyuncs.com.

Note

To ensure security, we recommend that you use https.

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',
});

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',
});