Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
424 stars 126 forks source link

[Bug]: Cart AJAX API returning 404 #4690

Open nboliver-ventureweb opened 3 days ago

nboliver-ventureweb commented 3 days ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Theme

Expected behavior

The AJAX API endpoints cart/add.js and cart/update.js should the dev theme preview available at http://127.0.0.1:9292

Actual behavior

The AJAX API endpoints cart/add.js and cart/update.js are returning 404s when using the dev theme preview at http://127.0.0.1:9292 CLI version 3.66.1 seems to work, but 3.67.1 and 3.68.1 do not. Using the --legacy flag does not fix the issue.

Request: Image

http://127.0.0.1:9292 Response: Image

Same request, same theme, but using the myshopify.com URL: Image

Verbose output

Can be shared via DM

Reproduction steps

  1. Run npm exec --package @shopify/cli@3.68.1 -- shopify theme dev --live-reload full-page (or try v3.67.1). Note that we are currently using npm exec because we rely on Shopkeeper, which was broken by CLI versions > 3.58, but the theme dev command is broken in that version. See https://github.com/Shopify/cli/pull/4469
  2. Visit http://127.0.0.1:9292 in browser
  3. Try to add or update via AJAX API
  4. Get a 404 response

Operating System

Mac OS Ventura

Shopify CLI version (check your project's package.json if you're not sure)

3.68.1

Shell

No response

Node version (run node -v if you're not sure)

v22.3.0

What language and version are you using in your application?

No response

montalvomiguelo commented 3 days ago

I was not able to reproduce the issue using the steps provided. Am I missing something?

https://github.com/user-attachments/assets/e73f625e-0253-442f-9aa0-bf681c515e42

cesarho commented 3 days ago

@nboliver-ventureweb

Check if the variant ID exists in your testing store. The update.js api returns a 404 error if the provided variant ID does not exist.

Image

nboliver-ventureweb commented 21 hours ago

@montalvomiguelo Thanks for checking and sharing that video. What is interesting is that I'm not getting a 404 this morning - same shop, same theme, same ID, same CLI version, same everything. I have seen the same thing come up once before on a different shop, but I thought it was because the shop was a B2B with required log in. I'll do some more testing today and if it doesn't come up again, close the issue.

@cesarho The variant ID definitely exists on the store - the same ID was used when testing on the preview theme, which was successful. The 404 response I'm getting also does not have the message / description show in the docs.

tpage99 commented 16 hours ago

I was getting 404s on Friday as well and just started using '--legacy' flag.

Haven't tested today but at least anecdotally, had the same experience last week.