Resolving a custom hostname during a request
When you create a custom hostname it's associated with either defaultContextId or defaultSiteId, or both. These IDs help determine access to specific applications supported by Sitecore. After your custom hostname is verified, it can be used to route traffic to the correct service based on its associated IDs.
Sitecore identifies the target service or application of your request, based on the hostname you use and whether you include the tenant name in the request URL. Here are the possible scenarios:
A custom hostname can retrieve media from any tenant inside the organization if you include the tenant name in the request URL. For example https://customhostname.io/v1/media/edge/images/<tenantName>/media/banner-image.jpg.
If you don't specify the tenant name in the URL, then the associated Context ID is used to resolve the tenant. For example https://customhostname.io/v1/media/edge/images/banner-image.jpg.
-
Use a custom hostname without
ContextIdorSiteIdIf you use a custom hostname in your request without explicitly including a
ContextIdin the query parameter or header, or aSiteIdin the query parameter or body, the system automatically uses thedefaultContextIdordefaultSiteIdlinked to that custom hostname. This simplifies your requests because you don't have to manually include those IDs every time.The system automatically uses the defaultContextId or defaultSiteId linked to the custom hostname, depending on the request type:
-
defaultContextIdis used to resolve tenant-specific requests, such as media requests made through/v1/media/edge/images/*. -
defaultSiteIdis used to resolve site-specific requests, such as GraphQL requests made through/v1/content/api/graphql/v1.
-
-
Use a custom hostname with
ContextIdorSiteIdIf you use a custom hostname along with a
ContextIdin the query parameter or header, or aSiteIdin the query parameter or body, the system will prioritize these provided IDs over the default ones associated with the hostname. -
Use the default hostname
If you use the default
edge-platform.sitecorecloud.iohostname, there are no specific IDs automatically associated with it. To make sure your request reaches the correct destination, you need to include either theContextIdorSiteIdin the request.
Custom hostname media item requests
Custom hostnames can only be used with the live context ID and for media items published to Experience Edge.
Media requests made through a custom hostname are resolved at the environment level and do not use a site ID. For this reason, defaultSiteId has no effect on media item requests made through /v1/media/edge/images/*. The associated defaultContextId is used to resolve the environment when a environment name is not included in the URL.
To prevent search engines from indexing your media on the http://edge.sitecorecloud.io domain, Experience Edge media requests include the X-Robots-Tag:noindex header.
However, when requesting a media item from a custom hostname, you can use the relative path /v1/media/edge/images/ to have the X-Robots-Tag:noindex header omitted from the response. This lets search engines properly index media items on your custom domain, improving SEO.
To make a media request using a custom hostname, reconstruct the URL to combine the custom hostname, relative path /v1/media/edge/images/, and relative path to the media item.
For example, if the Experience Edge media item URL is:
and your registered custom hostname is:
Then you can request the media item from the custom hostname URL:
Custom hostname GraphQL requests
- Without a configured
defaultSiteId, the site must be supplied explicitly. This exposes the site name in the request payload.
POST https://www.example.com/v1/content/api/graphql/v1
- With a configured
defaultSiteId, Sitecore automatically resolves the site associated with the hostname and while thesiteparameter must be included in every request, the site name does not need to be supplied.
POST https://www.example.com/v1/content/api/graphql/v1