This topic describes how to map a custom domain name to a bucket.

Object Storage Service (OSS) allows you to map a custom domain name to an OSS bucket based on a CNAME record. You can use this method to migrate data to OSS. For example, you have the domain name, and all your images can be accessed by using URLs in the following format: To access your images by using original URLs after you migrate the images to an OSS bucket, perform the following steps:

  • Activate OSS and create a bucket.
  • Modify the Domain Name System (DNS) configurations of the domain name. Add a CNAME record to map to an OSS endpoint such as
  • Log on to the OSS console to map to the created bucket.
  • Upload an image to the OSS bucket.

You can use the original URL to access the image that is stored in the OSS bucket. For more information about how to map custom domain names, see Map custom domain names.

To use your custom domain name as the endpoint of a bucket when you use OSS SDK for Browser.js, set cname to true. The following code provides an example on how to use your custom domain name as the endpoint of a bucket:

let OSS = require('ali-oss')

let client = new OSS({
  // Use a custom domain name mapped to the bucket as the endpoint of the bucket. 
  endpoint: 'Yourendpoint',
  // The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in OSS is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. 
  accessKeyId: 'YourAccessKeyId',
  accessKeySecret: 'YourAccessKeySecret',
  cname: true
Important If a custom domain name is mapped to a bucket, the domain name cannot be used to call the list_buckets operation.