I am creating an app with theme extension for one of my clients. I have setup app in Admin, where I load data from Shopify API. This part works well. For the theme extension, I created extension by generating it through shopify CLI. I implemented basic code where I want to call endpoint from my app, and load data. In app settings I updated the App url based on generated ngrok URL and added this URL to app proxy settings in which I set path to apps and subpath to proxy and set URL to https://***.eu.ngrok.io/api as my app endpoint is /api/inventory-level.
In my theme-extensions I am calling following request:
const url = `/apps/proxy/inventory-level?${new URLSearchParams({variantId: variantId})}`
return fetch(url, {
method: 'GET',
headers:{"Access-Control-Allow-Origin":"*"}
}).then((data) => {
console.log(data);
}).catch(e => {
console.log(e)
})
which calls :
https://foo.myshopify.com/apps/proxy/inventory-level?variantId=XYZ
and I get 404 error. I guess I am doing something wrong with App proxy setup, but from what I went through I understand that my setup is correct.
Also, when I go to ngrok URL, that is generated with run dev command, I get error ERR_NGROK_3200. I have tried removing and adding proxy, I uninstalled all apps from the store, but allways get the same result.
I will be glad for any advice. Thank you.