eCDN rules for Phased Headless Rollout
A phased headless rollout is a technique for delivering a single shopping experience using multiple storefront technologies like Storefront Reference Architecture (SFRA) and Composable Storefront.
An embedded CDN (eCDN) zone can route traffic to both SFRA and Managed Runtime at the same time, allowing you to gradually roll out a Composable Storefront.
This guide describes how to use Commerce API CDN Zones to route traffic to Managed Runtime.
- Familiarize yourself with Authorization for Admin APIs
- You must have an Account Manager API Client with the scope
- You must know the zone ID of the eCDN zone to be used with Managed Runtime. To get this info, use the getZonesInfo endpoint of the CDN Zones API.
- Use updateSecuritySettings to enable
alwaysUseHttpson the zone. Managed Runtime only supports traffic over HTTPS.
- Set your SLAS API Client’s
redirect_urito include the zone.
- If you have restricted the set of IPs allowed to access your Managed Runtime environment, add the CloudFlare IPs used by eCDN to the set of allowed IPs.
With the createMrtRules endpoint, you can create rules that route traffic to a Managed Runtime environment:
Let’s examine the data provided in the request body.
The value of
mrtHostname is the domain of the Managed Runtime environment for traffic routing. It must refer to a Managed Runtime environment hosted on the
mobify-storefront.com domain. If the provided value is used by an existing rule, the request fails.
Managed Runtime is the only supported routing destination.
The value of
expressions is an array of Cloudflare rule expressions that controls which requests are routed to Managed Runtime. For most implementations, a single routing expression is sufficient.
In addition to the provided expressions, the following default routing rules are used:
Routing changes are applied immediately, and navigating to a URL that matches an expression returns content retrieved from Managed Runtime.
Expressions are validated against the following criteria:
http.hostmust occur exactly one time and must be followed by the
eqoperator. The value must match the zone.
- The following fields are supported:
- The length of all expressions cannot exceed 3072 characters.
As you continue your phased rollout, you can route more requests to Managed Runtime.
To modify a routing expression, use getMrtRule to get the IDs of the ruleset and rule associated with the expression you want to update:
Next, use updateMrtRule to update the expression:
To disable routing use getMrtRule to get ruleset ID:
deleteMrtRuleset to remove Managed Runtime routing for that ruleset:
On environments where eCDN is not available, use the
composable-hybrid-dev-server to simulate eCDN routing.
To access the code, you need access to the Salesforce Commerce Cloud GitHub.