Navigation

Use a Custom Domain Name

On this page

Overview

You can use your own custom domain name for your hosted content. By default, content that you upload is available at a domain with the following form:

<Your App ID>.mongodbstitch.com

You can configure a custom domain name for your application’s hosted content from the Realm UI or by importing an application configuration directory that specifies the domain in its config.json configuration file. Select the tab below that corresponds to the method you want to use.

Procedure

1

Acquire the Custom Domain Name

You must own the custom domain name that you want to serve content from. If you don’t already own the domain that you want to use, you will need to purchase it from a domain name registrar.

2

Specify the Custom Domain in Realm

You need to provide your custom domain name to MongoDB Realm before it will serve content from the domain. To specify the domain:

  1. Click Hosting in the left-hand navigation.
  2. Click the Settings tab.
  3. Under Custom Domain, set the toggle to Enabled.
  4. Enter your custom domain in the input box under the Enabled toggle. This value should be the root domain without any subdomains. For example, you should enter example.com instead of www.example.com.
  5. Click Save.

Note

If an error is encountered during custom domain name validation, Realm sends the project owner an email alerting them of the issue.

3

Add a Validation CNAME Record

To verify that you own the domain you must add a new CNAME record in your domain’s DNS configuration. The Custom Domain section will include an information box that lists the host name and target value to use in the record.

Once you have added the validation record it may take some time for the DNS record to propagate. Realm will periodically check the domain’s DNS records for the validation CNAME and will mark the domain as verified if it finds the record.

Note

Realm may not be able to find the validation record if your DNS provider proxies requests for the domain. If Realm cannot validate your domain, ensure that you have disabled any HTTP proxies for the validation CNAME record on your DNS provider.

Note

If an error is encountered during custom domain name validation, Realm sends the project owner an email alerting them of the issue.

4

Add a Redirect CNAME Record

Once Realm has verified your domain, all that’s left is to add a CNAME DNS record for your domain that points to the default Realm domain. Use the following host name and target value:

Value Description
Host Name A subdomain such as www.
Target

The default domain for your application. This value is listed as the Realm Domain in the Settings tab of the Hosting page. The default domain has the following form:

<Your App ID>.mongodbrealm.com
1

Acquire the Custom Domain Name

You must own the custom domain name that you want to serve content from. If you don’t already own the domain that you want to use, you will need to purchase it from a domain name registrar.

2

Export Your Realm Application

To specify a custom domain name with realm-cli you need to export an application directory for your application.

You can export your application from the Export tab of the Settings page in the Realm UI, or by running the following command from an authenticated instance of realm-cli:

realm-cli export --app-id=<App ID>
3

Specify the Custom Domain

In config.json, set the value of hosting.custom_domain to your custom domain name then save the file.

"hosting": {
  "enabled": true,
  "custom_domain": "example.com"
}

Note

The value of custom_domain should be the root domain without any subdomains. For example, you should enter example.com instead of www.example.com.

4

Import the Application Directory

Once you have specified your custom domain name, you can import the application directory.

Navigate to the root of the application directory and run the following command:

realm-cli import --include-hosting
5

Add a Validation CNAME Record

To verify that you own the domain you must add a new CNAME record in your domain’s DNS configuration. You can find the host name and target value to use in the record Custom Domain section of the Hosting > Settings tab in the Realm UI.

Once you have added the validation record it may take some time for the DNS record to propagate. MongoDB Realm will periodically check the domain’s DNS records for the validation CNAME and will mark the domain as verified if it finds the record.

Note

Realm may not be able to find the validation record if your DNS provider proxies requests for the domain. If Realm cannot validate your domain, ensure that you have disabled any HTTP proxies for the validation CNAME record on your DNS provider.

Note

If an error is encountered during custom domain name validation, Realm sends the project owner an email alerting them of the issue.

6

Add a Redirect CNAME Record

Once Realm has verified your domain, all that’s left to do is to add one or more CNAME DNS records for your domain that point to the default Realm domain. Use the following host name and target value:

Value Description
Host Name A subdomain such as www.
Target

The default domain for your application. This value is listed as the Realm Domain in the Settings tab of the Hosting page. The default domain has the following form:

<Your App ID>.mongodbrealm.com