I am using AXIOS from within my app to access the shopify admin api. I am updating a customer with metafields (which, as I understand it, the storefront API does not support with graphql). I am receiving a preflight options error when I do a PUT. The error is a 404. The item I am trying to hit does in fact exist so I am wondering if shopify is mishandling the request or if I am missing something in my configuration.
Note: I am successfully able to do the same request through Postman. Postman is not doing an options preflight as far as I know.
My code:
axios({
method: 'PUT',
url: `https://${SHOPIFY_SHOP}/admin/customers/${decodedId}.json`,
auth: {
username: SHOPIFY_BASIC_AUTH_USERNAME,
password: SHOPIFY_BASIC_AUTH_SECRET,
},
data: {
customer: {
id: decodedId,
metafields: [
{
namespace: 'custom_fields',
key: 'organization',
value: org,
value_type: 'string',
},
{
namespace: 'custom_fields',
key: 'token_pro',
value: isPro,
value_type: 'integer',
},
],
},
},
}).then((data) => {
debugger
}).catch(( error ) => {
debugger
});
The errors
OPTIONS https://SHOP_NAME.myshopify.com/admin/customers/776734343229.json 404 (Not Found)
Failed to load https://SHOP_NAME.myshopify.com/admin/customers/776734343229.json: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3000' is therefore not allowed access.
Note that the customer does in fact exist at the time of this axios call.