What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Help needed with App Proxy not working

Help needed with App Proxy not working

fuller
Shopify Partner
25 0 41

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>  
Replies 9 (9)

fuller
Shopify Partner
25 0 41

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.

 

 

Daniel_Truong
Shopify Partner
25 1 6

I think it should be

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

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

fuller
Shopify Partner
25 0 41
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.
HunkyBill
Shopify Partner
4853 60 568

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
fuller
Shopify Partner
25 0 41

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

404errorUsingAppProxy.JPG

HunkyBill
Shopify Partner
4853 60 568

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
fuller
Shopify Partner
25 0 41

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.

 

 

 

HunkyBill
Shopify Partner
4853 60 568

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