> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrate a CDN resource with Magento

> Configure Magento Open Source and Adobe Commerce to serve static and media files through a Gcore CDN resource.

Magento Open Source and on-premises Adobe Commerce can generate static and media file URLs that use Gcore CDN while storefront pages continue to be served from the Commerce origin.

> [!NOTE]
>
> Adobe Commerce on cloud infrastructure includes Fastly CDN and uses a different integration workflow. This procedure applies to Magento Open Source 2.x and on-premises Adobe Commerce.

Administrator access to Commerce, an active CDN resource, and an HTTPS-enabled [custom domain](/cdn/cdn-resource-options/general/create-and-set-a-custom-domain-for-the-content-delivery-via-cdn) are required. Back up the Commerce files, database, and media before changing URL settings.

**1. Prepare the CDN resource**

Configure the storefront hostname — `shop.example.com` — as the CDN origin. Set the origin host header to the same hostname when the web server uses name-based virtual hosting.

Activate `cdn.example.com` as the HTTPS custom domain. Confirm that known files under the storefront static and media paths return successfully through the CDN domain.

The examples below assume that `pub` is the storefront document root, so the public paths begin with `/static/` and `/media/`.

**2. Open the web configuration**

Log in to the Commerce Admin and navigate to **Stores** > **Settings** > **Configuration**. Under **General**, select **Web**.

In the **Store View** selector, select the website or store view that will use Gcore CDN. Select **Default Config** only when the URLs should apply to every scope that inherits the global values.

**3. Configure the static and media URLs**

Expand **Base URLs** and clear **Use system value** for these fields:

* **Base URL for Static View Files**: Enter `https://cdn.example.com/static/`.

* **Base URL for User Media Files**: Enter `https://cdn.example.com/media/`.

Expand **Base URLs (Secure)** and clear **Use system value** for these fields:

* **Secure Base URL for Static View Files**: Enter `https://cdn.example.com/static/`.

* **Secure Base URL for User Media Files**: Enter `https://cdn.example.com/media/`.

Keep the storefront **Base URL**, **Base Link URL**, **Secure Base URL**, and **Secure Base Link URL** unchanged. Every CDN URL must end with a forward slash.

**4. Save and refresh the cache**

Click **Save Config**. Follow the **Cache Management** link in the confirmation message, or navigate to **System** > **Tools** > **Cache Management** and click **Flush Magento Cache**.

Keep static content signing enabled because its deployment version changes static URLs after storefront deployments and prevents stale browser or CDN content.

**5. Verify CDN delivery**

Open the storefront and use the browser developer tools:

1. Open the **Network** panel.

2. Reload a page that contains product images, theme styles, and scripts.

3. Select requests under `/static/` and `/media/`.

4. Confirm that their URLs use `cdn.example.com` and return successful responses.

## Integration troubleshooting

When static or media files fail to load from the CDN domain, the cause is usually a document-root path mismatch, an origin protocol or host-header error, a configuration scope that still uses the storefront domain, or a cache that still serves the previous URL.

* For a `404` response, confirm whether the origin web root exposes `pub`. If it does not, include `/pub/` in the CDN path or configure an equivalent origin rewrite.
* For a `502` response, verify the CDN origin pull protocol and host header.
* If browser fonts are blocked, configure the origin to return an `Access-Control-Allow-Origin` header for `https://cdn.example.com`.
* If static or media URLs still use the storefront domain, verify the selected configuration scope and flush the Magento cache.
* If an updated asset remains stale, deploy static content with the normal Commerce release process and purge the affected CDN cache.
