`theme dev` can't render market subfolder URLs on stores with a custom primary domain

Summary

On a store whose markets use subfolders on a custom primary domain, shopify theme dev can’t render those market URLs. Default-language subfolders return 404. Other languages return 200, but merchant content stays in the default language. The same theme renders all of these URLs correctly when previewed on the primary domain.

Environment

  • Shopify CLI: 5.0.1 (latest at time of writing)
  • OS: macOS 27.2 (arm64)
  • Node: 24.15.0
  • Shell: zsh

Store setup

  • Custom primary domain (example.com below). your-store.myshopify.com redirects to it.
  • Live URLs are all subfolders: /en-us, /es-us, /en-ca, /fr-ca. The root / redirects to /en-us.
  • Markets: US and Canada.
  • Languages: en (default), fr, es.

Steps to reproduce

  1. Run shopify theme dev -s your-store -t your-theme.
  2. Open /en-us, /en-ca, /es-us, and /fr-ca on http://127.0.0.1:9292.
  3. Open the same paths on the primary domain with the same theme, e.g. https://example.com/fr-ca?preview_theme_id=<dev theme id>.

Expected behavior

Market URLs render locally the same way they do on the primary domain, with the right language, market, and root path.

Actual behavior

Path theme dev Primary domain, same theme previewed
/en-us 404 200, Shopify.routes.root is /en-us/
/en-ca 404 200, Shopify.routes.root is /en-ca/
/es-us 200, Shopify.locale is es-US, Shopify.routes.root is /es/, merchant content in English 200, Shopify.locale is es, Shopify.routes.root is /es-us/, translated
/fr-ca 200, Shopify.locale is fr-CA, Shopify.routes.root is /fr/, merchant content in English 200, Shopify.locale is fr, Shopify.routes.root is /fr-ca/, translated

Other behavior on the local server:

  • Any fr-XX or es-XX prefix returns 200, including /fr-be and /es-mx, and the suffix is copied into Shopify.locale. Any en-XX prefix returns 404.
  • Theme strings on these pages do come from fr.json and es.json, so the page is partly translated. Content translated in Shopify is not.
  • Links on /fr-ca point to /fr/..., so navigating leaves the market URL. /fr itself is a 404 on the primary domain.
  • /?country=CA redirects to /en-ca, which then returns a 404.

Reproduction without the CLI

These requests reproduce the same behavior against the published theme, with no dev server running:

curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' 'https://your-store.myshopify.com/fr-ca'
# 301 https://example.com/fr-ca

curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' 'https://your-store.myshopify.com/fr-ca?pb=0'
# 301 https://example.com/fr-ca?pb=0

curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' 'https://your-store.myshopify.com/fr-ca?_fd=0'
# 200

curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' 'https://your-store.myshopify.com/en-ca?_fd=0&pb=0'
# 404