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.

Script Tag - AJAX request for getting data from app for the storefront.

Script Tag - AJAX request for getting data from app for the storefront.

Kyon147
Shopify Partner
7 1 2

Hi all,

 

Building an app where I want to load a modal on a customers Shopify site. However, to do so I need to be able to fire an AJAX call to the app to get the relevant information to populate the modal.

 

As the domain is external to Shopify, there is the CORS issue.

 

I've tried searching for a solution but it does not seem readily available. What's the best way to approach this?

Replies 2 (2)

Masterminds
Visitor
1 0 3

Finally, someone else is on the same issue. We're all brothers in arms here. For some reason, almost as if by design, Shopify support/admins on here will never give you a straight answer.

 

I'm looking for the same thing too. Last I've read on here, you have to "What you can do is from your front end, delegate to your backend to make the request, and return the response data from that request to your front end." Unfortunately, that's very vague. They're probably just going to tell you to hire an expert, and not answer the issue publicly.

 

https://community.shopify.com/c/Shopify-APIs-SDKs/Using-APIs-from-a-different-origin-domain/td-p/502...

Kyon147
Shopify Partner
7 1 2

Yeah, there seem to be some "ways" floating about such as using JSONP but they don't seem like a solution but more a "hack" to get it to work for cross-browser requests.

 

App Proxy seems another way but is aimed towards render pages with custom content rather than serving content from Javascript using API requests. 

 

Apps out there have done this look at Privy, Ultimate Special Offers etc they all have on-page modals and such which require talking to their app from another domain. It's just not well documented seen as it's meant to be a big thing the Script Tag.