Hi there,
i am calling cartcreate mutation from my backend (after sending session token from customer account ui extension frontend)
it is giving 401 error. any idea what is wrong here? below is the code
const mutation = `mutation cartCreate($input: CartInput) {
cartCreate(input: $input) {
cart {
id
checkoutUrl
totalQuantity
cost {
totalAmount {
amount
currencyCode
}
}
lines(first: 10) {
edges {
node {
id
quantity
merchandise {
... on ProductVariant {
id
title
product {
title
}
}
}
}
}
}
}
userErrors {
field
message
}
}
}
\`;
const variables = {
input: {
lines: [
{
quantity: 1,
merchandiseId: “gid://shopify/ProductVariant/50652074639680”
}
\]
}
};
const response = await fetch(url, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
// ‘Authorization’: `Bearer ${storefrontAccessToken}`,
‘X-Shopify-Storefront-Access-Token’: storefrontAccessToken,
‘Shopify-Storefront-API-Version’: “2025-10”,
},
body: JSON.stringify({
query: mutation,
variables: variables
})
});