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

strideapps
New Member
2 0 2

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 ?




Reply 1 (1)
L4webdesign
Tourist
9 0 2

Hey @strideapps , do you have any updates on that? I am currently in the same situation and I'm not quite sure how to handle this.

 

currently I have three app-extension-directories in my project: local, stage, live.

 

I have to push each app-extension seperately and that is very inconvient. Do you have a better workflow?