Help & Documentation>Cloud Object Storage>SDK Documentation>Mini Program SDK>Setting Access Domain Names (CDN/Global Acceleration)

Setting Access Domain Names (CDN/Global Acceleration)

Last updated: 2023-09-13 10:52:14

Feature Overview

This document describes how to request the COS service by using a non-default domain name.

Parameter description

Control the request domain name by initializing parameters. The relevant parameter descriptions are as follows. For more information on initialization parameters, see Configuration Options.
Parameter
ParameterDescription
Local Disk Types
Required
Domain
The custom request domain name used to call a bucket or object API. You can use a template, such as "{Bucket}.cos.{Region}.myqcloud.com" which will use the bucket and region passed in the replacement parameters when an API is called.
String
Not required
Protocol
The protocol used when the request is made. Valid values: https:, http:. By default, http: will be used when the current page is determined to be in http:; otherwise, https: will be used.
String
Not required

Default CDN Acceleration Domain Name

The sample code below shows how to access a COS service using a default CDN acceleration domain name.
var cos = new COS({
Domain: '{Bucket}.file.myqcloud.com', // Custom acceleration domain. The Domain parameter supports templates. In this example, {Bucket} will be automatically replaced with the input Bucket during the request.
Protocol: 'https:', // Request protocol: 'https:' or 'http:'
});

Custom CDN acceleration domain name

The sample code below shows how to access a COS service using a custom CDN acceleration domain name.
var cos = new COS({
Domain: 'example-cdn-domain.com', // Custom acceleration domain name
Protocol: 'https:', // Request protocol: 'https:' or 'http:'
});

Custom origin domain name

For more information, see Enabling Custom Origin Domain.
The sample code below shows how to access a COS service using a custom origin server domain name.
var cos = new COS({
Domain: 'example-cos-domain.com', // Custom origin domain name
Protocol: 'https:', // Request protocol: 'https:' or 'http:'
});

Global acceleration domain name

For more information on global acceleration, see Overview.
The sample code below shows how to access a COS service using a global acceleration endpoint.
var cos = new COS({
UseAccelerate: true, // Specify true to request using the GAAP domain name
Protocol: 'https:', // Request protocol: 'https:' or 'http:'
});