Hi,
I’ve been trying to develop a new tile for the POS using POS-UI Extension.
But, when trying to get the last 3 orders, I encounter a CORS error.
Here is my fetch request:
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": `${sessionToken}`,
"Access-Control-Allow-Origin": "*",
mode: "no-cors"
},
body: JSON.stringify({
query: `
query {
orders(first: ${number}, reverse: true) {
edges {
node {
id
name
createdAt
}
}
}
}
`,
variables: {}
})
});
And here is the Chrome Inspect error:
Access to fetch at 'https://my-store.myshopify.com/admin/api/2024-04/graphql.json' from origin 'https://cdn.shopify.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Is there anything I can do ?
Thanks for your help.