CLI is serving incorrect CDN assets

I have reproduced the issue on the latest CLI version.

Yes, I am on the latest version

I have searched existing posts and this report is not a duplicate.

Yes, this isn’t a duplicate

In which of these areas are you experiencing a problem?

Theme

Expected behavior

Theme asset files and asset files bundled with apps installed on the store should coexist peacefully when developing locally.

Actual behavior

I’m working on a store which has the Klaviyo Email Marketing app installed. This app bundles a script file, app.js, which has the same name as an asset in my theme. When developing locally, the CLI is serving the contents of my theme’s asset file at the URL of the app’s asset file, causing issues (such as double-binding of event handlers).

My theme code includes this script tag in the <head>:

<script src="/cdn/shop/t/49/assets/app.js?v=84033011345432651421779917604" defer></script>

In the content_for_header hook, the app renders a script tag for its asset:

<script src="/cdn/extensions/019e1813-804f-7f97-ad2d-278904fdd92f/klaviyo-email-marketing-54/assets/app.js" type="text/javascript" defer="defer">

In the storefront environment this works fine. However when developing locally, the second script URL returns the contents of the app.js asset file in the theme, not that of the Klaviyo app.

Reproduction steps

I have not tried this with any other apps, but in theory it should be possible to:

  1. Install an app that bundles an asset file (script/stylesheet)
  2. Create an asset file in the theme with the same name as the app’s asset file
  3. Observe that the contents of the theme’s asset file are served in response to a request for the app’s asset file

Verbose output

N/A – the CLI doesn’t log anything when proxying CDN requests

Operating system

macOS Sequoia

CLI version

@shopify/cli/4.1.0 darwin-x64 node-v26.0.0

Shell

iTerm2/bash

Nodejs version

v20.20.0

Hi @JamesTiplady :waving_hand: thanks for reaching out.

I’m doing some digging on this and I’ll follow up with you here as soon as I have more to share.