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.

No comments:

Post a Comment