Help needed with App Proxy not working

Highlighted
Shopify Partner
25 0 12

appProxyShopify.JPG

 

My PartnerDashboard->App proxy settings are set as such.

My Proxy URL is set.   and runs fine in its own browser tab.

 

I'm getting a 404 error when I make this call from 'product-template.liquid'

<script>
  $.get('/tools/getprice', function( data ) {
    alert ( "DATA: " + data );
  });
</script>  
0 Likes
Highlighted
Shopify Partner
25 0 12

I tried something different and it works.  Instead of doing a $.get() using the Subpath Prefix and path, I used 

the Proxy URL as the $.get() path. 

 

This doesn't make sense and feels like it goes this goes against what Shopify documentation says, but then again

I do find the documentation confusing.  I wish Shopify would show us some clear javascript and jquery examples.

 

 

0 Likes
Highlighted

I think it should be

<script>
  $.get('/tools/getprice/', function( data ) {
    alert ( "DATA: " + data );
  });
</script>  
Shopify App & Theme Developer
0 Likes
Highlighted
Shopify Partner
41 0 8

can i ask what is the advantage of using app proxy?

0 Likes
Highlighted
Shopify Partner
25 0 12
I was looking for a way to pull external data in Shopify, that is to get price and stock on hand from the external database. After reading through many community posts it was suggested that an app proxy is how you do this.
0 Likes
Highlighted
Shopify Expert
4124 29 383

Note that while you could use a proxy call to get data from an external database, like price and quantity, that would have no impact on Shopify since the price and quantity are set in stone in Shopify (unless you use an external fulfillment service as your inventory manager with Shopify).

 

The main reason you'd use an App Proxy is security. It allows you to make a callback to a service you control, out there in the wild, so you can get data, and then do something with it on the Shopify page you called from.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
1 Like
Highlighted
Shopify Partner
25 0 12

Was a good thought and I had tried that previously and again today, but still see a 404 error.

404errorUsingAppProxy.JPG

0 Likes
Highlighted
Shopify Expert
4124 29 383

You call the subpath_prefix + subpath using JS. So ya... fetch('/tools/fizzbuzz') for that or $.get('/tools/fizzbuzz') or $.post('/tools/fizzbuzz'). 

 

That is not what is generating the 404. The 404 comes from Shopify taking your data, and trying to call your actual App at the Proxy URL. 

 

So it seems your Proxy URL is not setup to respond to a GET request. Hence, the 404. So ensure your App is configured to listen to /tools/getprice. 

 

Note that even if you get a price back, what would you do with it? It is nothing but a suggestion or decoration right? Is it some kind of compare at price?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
1 Like
Highlighted
Shopify Partner
25 0 12

Hi HunkyBill (a great handle btw),

 

Thanks for your comments on the 404 error.  You are likely correct about my proxy URL

not set-up to handle a GET request.  I will mention this to the programmer, but it sounds

like I will be dropping the need of using an app proxy.

 

As you suggest, it probably is serving little purpose, so yeah, a decoration.

 

I'm just starting to read up on fulfillment services that you suggested in your previous comment.

 

 

 

0 Likes
Highlighted
Shopify Expert
4124 29 383

If you set it as such, Shopify will send a query direct to your service, and ask the direct question, "Hey, dude! How much of this thing is in stock".

 

That way, you control what the peoples can buy and how much. The implication though is that you best be sure your service is up 24/7 or you be in some kind of mess. Like running your own shipping rates service. Comes with great responsibility.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes