Testing Shopify app in local host without using ngork token or cloudfare

Wedevagency
Shopify Partner
124 0 1

Hi all,

 

Is it possible to test Shopify cli3 without using ngork token, ngork or cloudfare and only using local host alone to test.

banned
Replies 4 (4)

glassit
Shopify Partner
20 1 2

Hi @Wedevagency 

 

This is Glass It, a price tracking solution which can improve your profit margins. It is possible to test your Shopify App without using ngrok. You need to configure your web server accordingly, and also have a domain name available pointing to your server. For example, in Apache here are some example configuration snippets to make sure front-end and back-end requests from the REACT/PHP Shopify app are handled properly:

 

ProxyRequests Off
ProxyVia Full
ProxyPreserveHost On

<Proxy *>
Require all granted
</Proxy>

 

# Serve backend & frontend on same domain - See example http://ceres.com.vn/blog/setup-environment-to-develop-shopify-application-using-php-and-react/
# BACK END
ProxyPass /api/ http://127.0.0.1:8000/api/
ProxyPassReverse /api/ http://127.0.0.1:8000/api/

 

# FRONT END
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/

 

However it may not be possible to test only using local host because Shopify must be able to reach your App Url, and localhost isn't accessible over public networks.

 

Hope this helps! Please mark answer appropriately if you find this answer helpful.

Wedevagency
Shopify Partner
124 0 1

@glassit Thank you for your response. What commands would I use in cli3? If I'm just using local host.

banned
glassit
Shopify Partner
20 1 2

There is no Shopify cli3 command that will be useful to run your app using localhost. You have to run a web server (like Apache, nGinx, etc) on your development machine, upload/move your Shopify App files to the local web server on your development machine, then make your local web server available to the Internet by opening a port on your network which forwards request traffic to your local web server. Then you would provide your public IP address (or a domain name pointing to your development IP address) which is forwarding the port traffic to your local web server in the Shopify App URL field. You would also need to setup an SSL certificate on your local web development server to handle https:// secure traffic because when Shopify make requests to the App URL, it must be secured. Finally, https://localhost and http://localhost are not publicly accessible URLs. These are used only for making connections locally on your machine. Therefore it is not possible to use https://localhost or http://localhost in the App URL field to test your Shopify App, because Shopify will not be able to communicate with these URLs.

 

The Shopify cli3 command 'npm run dev' takes care of all of that setup with the web server without you needing to forward any network ports or install any additional web server, which is very useful to speed up the development phase of your Shopify App. 

JorensM
Shopify Partner
6 0 3

Hi Glassit,

 

I believe that Wedevagency wanted to know if it's possible to test an app completely locally, without having to connect to Shopify. So something like hosting a Shopify store locally and connecting the app to that local store, instead of connecting it to a store hosted on Shopify. That's what I was looking for, at least. But it doesn't seem possible.