Theme app extension, how to detect stage vs live environment.

strideapps
New Member
2 0 1

Hi Guys,

I am currently converting my script tag based app to a theme app extension. 


When using the script tag, it was easy to figure out if the app is being loaded from our stage or live server. I used to simply search for the loaded script on the page and see if the URL contains ngrok.io or not. Something like that:

document.querySelector('script[src*='+APP_SLUG+'.strideapps.ngrok.io]');

 

Based on that, I would then use the correct domain to access the app API.

But now with the theme app extension, I am not sure how to make this detection. Whether it's the staging or live app, the script is being loaded by Shopify and there is no way to differentiate them. 

Any idea how would you do that ?