Hello,
I am trying to show some products of merchants in my theme app extension block.
I don’t understand how can I communicate from my theme app extension block to the backend of my app. I am using the template that the Shopify v3 CLI gave me with Express in the backend. I set up an App Proxy, but I can’t catch the requests in the Express Server that I send from the client to my backend. The requests always show HTTP status 200.
My App Proxy configuration is this:
- Subpath prefix: apps
- Subpath: adara
- Proxy URL: https://<<Ngrok ID>>.sa.ngrok.io/api
My client code is this:
(async () => {
const ids = ["gid://shopify/ProductVariant/1234567890", "gid://shopify/ProductVariant/1234567891"];
const fetchOptions = {
method: "GET",
headers: {
"Content-Type": "application/json",
}
};
const response = await fetch(`/apps/adara?ids=[${ids}]`, fetchOptions);
console.log(response);
})();
In web/index.js I write a new route in the Express Server:
app.get("apps/adara", (req, res) => {
res.status(201).send("Succeed")
})
Even if I put it on top of the other routes, I can’t catch the request. I have also tried the route “*” without success.
Is there something that I am missing?
If I want to make a GraphQL query to the admin API, do I need anything else in order to make the request inside the Express route?
Thanks in advance.