Skip to content

Theme CLI dev server returns 429 on cart requests (bot mitigation false positive) #1142

@stephanie-shopify

Description

@stephanie-shopify

tldr

people using the CLI are getting erroneously flagged as bots, particularly on cart requests.

Summary

Merchants using theme dev are getting 429s on cart Ajax requests (/cart.js, /cart/add, /cart/update.js, etc.), causing storefront JS to break when it receives an HTML
  challenge page instead of JSON.

 Root cause:
 Cloudflare's heuristic bot classifier is scoring CLI proxy requests as BotScore=1 (definite bot) Cart requests are the most affected because they deliberately omit the Bearer token — sending it would cause SFR to use token auth, which lacks cart scopes and breaks cart functionality Without the Bearer token, Cloudflare has no signal to identify these as legitimate CLI traffic, so they get flagged

 impact of problem (last 24h):
 41k 429 events on  468 unique developer IPs affected

 Current status:
 - Non-cart CLI requests are largely fine — Bearer token gives Cloudflare something to work with
 - Cart/checkout/account are the gap — they can't carry a Bearer token
 - We need a reliable exemption signal for these paths
 - Header-based approaches (e.g. custom X-Shopify-CLI header) are spoofable and not viable alone

  • Session cookies on cart requests are Shopify-issued and a potential candidate
    Reproduced on latest CLI version.

Merchant report (verbatim)

Actual behavior:

POST http://127.0.0.1:9292/cart/add.js 429 (Too Many Requests)
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Uncaught TypeError: Cannot read properties of null (reading 'body')

Reproduction steps: Click "Add to Cart" a few times rapidly.

Environment: Mac OS Tahoe, CLI 3.88, Node 22.21.1

more recent report: https://community.shopify.dev/t/cli-theme-dev-cart-ajax-401/28826/48?u=josh-shopify

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions