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.

401 App Proxy

401 App Proxy

wefbunadi
Visitor
1 0 0

Hi, I have unlisted Shopify app and I have setup App Proxy with prefix as "a" and subpath as "customer-meta". I have supplied the full URL of the php file under Proxy URL. I use laravel-shopify for my unlisted app. 

 

On the Shopify's liquid theme, I have an ajax call (GET) to the app proxy. 

 

$.ajax({
        method: "GET",
        crossDomain: true,
        url: "/a/customer-meta",
        data: $("#custmeta").serialize()
      })
      .done(function( response, textStatus, jqXHR ) {
          
          $( "#updatebutton" ).prop("disabled", false);
          $( "#updatebutton" ).html("SAVE / EDIT CHILD");
          
          if(response == 'success'){
            $( "#dialog-message" ).dialog({
              modal: true,
              buttons: {
                Ok: function() {
                  $( this ).dialog( "close" );
                  location.reload();
				}
              }
            });
            
          } else {
            $( "#dialog-error-message" ).dialog({
              modal: true,
              buttons: {
                Ok: function() {
                  $( this ).dialog( "close" );
                }
              }
            });
          }     
      })
      .fail(function( jqXHR, textStatus, errorThrown ) {
          $( "#updatebutton" ).prop("disabled", false);
          $( "#updatebutton" ).html("SAVE / EDIT CHILD");
          
          var errorMessage = jqXHR.status + ': ' + jqXHR.statusText + '\n';
          errorMessage += 'Please check your data and try again. If this error continues, please contact us for assistance.';
          
          alert('Error - ' + errorMessage);
      });

I'm unable to replicate the 401 error message however a lot of my customers are saying they're getting 401 error message ($.ajax.fail condition). I checked my website statistic and there is 63% rate of 401. I'm using offline access token so the token itself shouldn't expire so I'm not sure why some users are getting 401 error and some not. 

 

Any help will be really appreciated. Thanks!

Reply 1 (1)

Alex
Shopify Staff
1561 81 343

If the 401s are occurring on your server, can you indicate exactly where the 401 is occurring? To be more specific, is there a stack trace you can share if it's due to an exception, or is there an HTTP request you're making upstream which is resolving to a 401, which you are sending back to the ajax client? More info is much appreciated.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog