Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Safari bug on product pages #153

Open
fhorstmann opened this issue Mar 7, 2019 · 2 comments
Open

Safari bug on product pages #153

fhorstmann opened this issue Mar 7, 2019 · 2 comments

Comments

@fhorstmann
Copy link

getting two js errors on the product detail page: 1). the product js script fails to load and shows a 401 (Unauthorized) error and 2). An Unhandled promise rejection SyntaxError (DOM Exception 12). I haven't touched the core theme files so I'm not sure why these errors would show up only in Safari unless the theme has a bug? Chrome and Firefox don't show any errors in the console. The error prevents me from being able to add anything in the cart and when doing so sends me to a new page /cart/add that says, "Parameter Missing or Invalid: Required parameter missing or invalid: id".
screenshot 2019-03-05 21 32 46

@badantlerday
Copy link

Any news on this?

@studio404pl
Copy link

studio404pl commented Jun 26, 2019

@fhorstmann @badantlerday find function getProductJson() here:
https://github.com/Shopify/starter-theme/blob/master/src/scripts/sections/product.js#L62

and change it to:

getProductJson(handle) {
    return fetch(`/products/${handle}.js`, {
      credentials: 'include'
    }).then((response) => {
      return response.json();
    });
  },

it gets rid of 401 error and any further complications.

Looks like Safari default policy is different than in other browsers and passing credentials have to be forced. Here are the details:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Sending_a_request_with_credentials_included

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants