Tuesday, May 4, 2021

Running cordova with supervisor

 supervisor helps you automatically restart your process when something in your directory, or any type of files changes.  This is particularly helped for developers making changes to their code base. They need not manually restart the server for each change. supervisor can take care of restarting.

To install supervisor globally, use:

# sudo npm install supervisor -g

When running a cordova server locally for testing, in order to use supervisor, use the following:

$ supervisor --ignore platforms -- /usr/local/bin/cordova run <platform>

For example:

$ supervisor --ignore platforms -- /usr/local/bin/cordova run browser

The --ignore platforms is required, else, during the build, the code gets changed in the platforms folder, and supervisor will unnecessarily restart the process.

Friday, April 23, 2021

Running a local server, but using the production domain

Say you are building www.mycooldomain.com and want to test your changes locally, but using the www.mycooldomain.com domain itself in your browser.


Option 1: Use /etc/hosts file (works on both linux and mac machines)

Add an entry to your /etc/hosts file, like below:

127.0.0.1    www.mycooldomain.com


This option works as long as you do not want https to work. However, if you want https also to work, go for option 2.


Option 2: Using Charles proxy on a mac

Step 1: Install Charles Proxy, and add a setting under Tools -> Map Remote like the one below:



Step 2: Then, in the Charles proxy app, go to Help -> SSL Proxying -> Install Charles Root Certificate.  Once the certificate is installed, in the Keychain Access app, double click on the Charles Proxy CA certificate, click on Trust, and choose "Always Trust" for "When using this certificate".

Now you are all set to test with your prod domain, running locally.