Endpoint配置

更新时间:

本文为您介绍V1.0 Node.js SDK中Endpoint如何配置。

V1.0 Node.js SDK只支持在客户端初始化时,通过用户自定义Endpoint来配置。在自定义Endpoint时,需要在Endpoint前添加http://或者https://,例如https://ecs.cn-beijing.aliyuncs.com

说明

为了保证通信更加的安全,建议您使用https

RPC客户端配置示例:

const RPCClient = require('@alicloud/pop-core').RPCClient;

const client = new RPCClient({
    // 从环境变量中获取RAM用户的AccessKey ID
    accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,
    // 从环境变量中获取RAM用户的AccessKey Secret
    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',
});

ROA客户端配置示例:

const ROAClient = require('@alicloud/pop-core').ROAClient;

const roaClient = new ROAClient({
    // 从环境变量中获取RAM用户的AccessKey ID
    accessKeyId: process.env.ALIBABA_CLOUD_ACCESS_KEY_ID,
    // 从环境变量中获取RAM用户的AccessKey Secret
    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',
});