Adobe Commerce · updated

What goes in config.json for the Edge Delivery commerce boilerplate?

The storefront reads one JSON file that tells it which Commerce endpoints to call and which headers to send. Under public.default it holds commerce-core-endpoint, commerce-endpoint, a headers object and an analytics object. Extra keys named after a root folder, such as /en-ca/, override the default for one store view. The file is fetched by the browser, so nothing in it is secret.

In plain words

This file is the storefront's address book. It says where the shop's data lives and which shop, language and website to ask for. Get it wrong and pages load but products do not.

Where the file lives

Adobe's page says you find the configuration in your code repository at /config.json, or in the configuration service for your site, and that a config.json in the repository takes precedence over the site's public configuration. The boilerplate ships demo-config.json as a sample to copy, and default-site.json as the template for the configuration service.

The boilerplate's scripts/commerce.js fetches /config.json from the site's own origin and keeps it in the browser's session storage with an expiry two hours ahead.

The keys

KeyWhat Adobe says it is
commerce-core-endpointCore GraphQL endpoint for queries and mutations. Handles all write operations and some reads.
commerce-endpointServices GraphQL endpoint for read-only operations: Catalog Service, Live Search and Product Recommendations.
headers.all.StoreStore view code for core GraphQL requests.
headers.cs.Magento-Store-CodeIdentifies the store to connect to.
headers.cs.Magento-Store-View-CodeIdentifies the store view for Catalog Service requests.
headers.cs.Magento-Website-CodeIdentifies the website to connect to.
headers.cs.x-api-keyThe API key for the SaaS services: Catalog Service, Live Search and Product Recommendations.
headers.cs.Magento-Environment-IdConnects the storefront to the cloud instance serving it.
analyticsStore, store view and website names and IDs, the base currency code and the environment. Two optional keys enable forwarding to Adobe Experience Platform when both are present.
plugins.picker.rootCategoryThe root category ID for the product picker.
commerce-assets-enabled, commerce-b2b-enabled, commerce-companies-enabledSwitches for AEM Assets in the storefront, B2B logic and company features. Company features need the B2B switch set to true.

How the code uses them

  • The core client uses commerce-core-endpoint and falls back to commerce-endpoint when the first is missing. It sends the headers under headers.all.
  • The Catalog Service client uses commerce-endpoint and sends headers.all plus headers.cs.
  • The boilerplate adds a short cache-busting parameter, cb, to Catalog Service requests, worked out from the cs headers.

Differences by platform

PlatformWhat changes
Adobe Commerce PaaSStandard Adobe Commerce header names, and API keys are required for the SaaS services.
Adobe Commerce as a Cloud ServiceStandard header names, but no API key or environment ID in the default configuration. You only need to set commerce-endpoint: the same endpoint is used for catalogue and core.
Adobe Commerce OptimizerDifferent header names under cs, such as AC-View-ID (required) and AC-Price-Book-ID (optional), instead of the Magento-* store headers.

More than one store view

Each key under public other than default must match the root folder path of a store view, for example /en-ca/. Adobe says each such configuration merges with the default at runtime. An empty object inherits everything. The drop-in tools code picks the key with the most path segments that matches the page's address.

The public part of the template (default-site.json in Adobe's boilerplate), with its placeholders. Shortened: the analytics and plugins objects are left out

{
  "public": {
    "default": {
      "commerce-core-endpoint": "{ENDPOINT}",
      "commerce-endpoint": "{CS_ENDPOINT}",
      "headers": {
        "all": { "Store": "default" },
        "cs": {
          "Magento-Store-Code": "{STORE_CODE}",
          "Magento-Store-View-Code": "{STORE_VIEW_CODE}",
          "Magento-Website-Code": "{WEBSITE_CODE}",
          "x-api-key": "{COMMERCE_API_KEY}",
          "Magento-Environment-Id": "{COMMERCE_ENVIRONMENT_ID}"
        }
      }
    }
  }
}

A store view override, holding only what differs from default (our example, in the shape Adobe's multistore page shows)

"/en-ca/": {
  "headers": {
    "all": { "Store": "en_ca" },
    "cs": { "Magento-Store-View-Code": "en_ca" }
  }
}

What to check when products do not load

  1. Open /config.json on your site in a browser. If it is missing, the storefront has nothing to connect to.
  2. Check that commerce-endpoint is the services endpoint and commerce-core-endpoint the core one. On Adobe Commerce as a Cloud Service they are the same address.
  3. Compare the three Magento-* codes with the store, store view and website codes in the Commerce Admin. Adobe's multistore page says they must match.
  4. On PaaS, check that x-api-key and Magento-Environment-Id are present under headers.cs.
  5. Remember the two-hour copy in session storage: open a new browser session after changing the file.

Related tools and pages on this site

Questions

Is the API key in config.json a secret?

It is sent to every visitor's browser, because the browser fetches /config.json. Treat everything in the file as public and never put a private or integration key in it.

Do I need both endpoint keys?

On Adobe Commerce as a Cloud Service Adobe says you only need commerce-endpoint. The boilerplate code falls back to it when commerce-core-endpoint is not set.

Which wins, the repository file or the configuration service?

The repository file. Adobe says a config.json on the production branch takes precedence, so changes in the configuration service will not replace it.

Does the query builder on this site write this file?

No. It writes GraphQL queries and the request around them. The file format is shown above as Adobe publishes it.

Sources

Facts about Adobe's products on this page are from the linked Adobe pages, read on the date shown beside each. Explanations, steps and examples are ours unless marked as Adobe's. If Adobe's page and this one differ, Adobe's page is right.

Surge Migrate is not affiliated with Adobe and claims no Adobe partner status. Adobe product names are trademarks of Adobe.

Surge Migrate

Moving the website itself

This page answers one Adobe Commerce question. Surge Migrate moves a website from any CMS to any CMS. Converted automatically. Checked before you install.

  1. 1

    Scan

    Names the system behind your site, counts pages and templates, lists the blocks to build and the work no tool does, and gives an effort range with its working.

    Scan a site →
  2. 2

    Convert

    Each page becomes an Edge Delivery document, an AEM Core Component page and import files for 7 other systems. 10 pages free; 500 or 2,000 pages in one paid run.

    Convert your pages →
  3. 3

    Verify

    A download is offered only when its own format check passes. The report lists every field not found and every component kept as plain content. Compare old and new pages side by side.

    Parity check →
  4. 4

    Install

    You import with the target system's own tool, on your own environment. Each download's README gives the command. Your system changes only when you run it.

    How each import was tested →