Reputation: 1021
I've used Shopify-CLI to generate an app and I've configured the app proxy as:
Prefix: tools
Subpath: sb
Proxy: https://xxx.ngrok.io/sb
In the theme.liquid page, I'm trying to access this as:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// Typical action to be performed when the document is ready:
var response = xhttp.responseText;
console.log("Sb ok"+ response);
}
};
xhttp.open("GET", "/tools/sb/sessions", true);
xhttp.send();
I'm able to hit https://xxx.ngrok.io/sb/sessions on my browser and get a valid response.
But the AJAX request constantly giving me a 404 on my test store. I've been able to configure an app proxy successfully using a different test app, and the only difference is this is a public app while the previous one was a custom app. I initially had a conflicting config i.e. /a/sb for both apps, but I've tried changing it to /a, /apps, /tools, with and without the subpath with no luck. I've even deleted the previous app to avoid any unexpected conflicts.
Thanks in advance!
Upvotes: 2
Views: 992
Reputation: 1021
Found the problem. Because I used the same prefix and subpath as the previous app (accidentally) when I first configured the app proxy, Shopify automatically suffixed a -1 to the proxy definition and the only way to change that was to go to the store and change the config. Changing the proxy URL in the partners/app setup flow didn't help.
Upvotes: 3