Getting HTTPS to work in your local dev station (OSX)
In order to be as close to possible from prod and avoid wasting time on API/Oauth request not working due to the lack of SSL it's important to use SSL in local development.
This guide will show you how to configure your machine to be able to access the React app and the API over SSL.
1. Updating the environment variables in the API and UI apps
We will have the following config:
- APP API: https://api.squadlytics.dev:3001
- AUTH API: https://auth.squadlytics.dev:3001
- React App: https://.squadlytics.dev:8090
Rails backend envs
In your backend repository, edit the
.env file at the root of your repository and make sure you have the following line:
Restart the backend using
React app envs
In your React app edit the
.env.local file at the root of your repository and make sure that you have the following lines:
REACT_APP_SQUAD_API_URL=api.squadlytics.dev:3001 REACT_APP_SQUAD_AUTH_URL=auth.squadlytics.dev:3001 REACT_APP_DOMAIN=squadlytics.dev:8090
Restart the UI using
2. Configuring dnsmasq
Clone this repository and setup dnsmasq (enter your account password when asked).
git clone firstname.lastname@example.org:squadlytics/local-ssl-development.git cd local-ssl-development ./config_dnsmasq.sh
Add local DNS to search order in System Preferences
You now need to add your localhost as a DNS server to your network settings.
System Preferences > Network > Wi-Fi (or whatever you use) > Advanced... > DNS > add 127.0.0.1 to top of the list.
Try to ping any subdomaing of squadlytics.dev to make sure that it resolves to 127.0.0.1
3. Configuring local-ssl-proxy
Now that we can use any *.squadlytics.dev domain locally we need a SSL proxy. We will use https://github.com/cameronhunter/local-ssl-proxy for that.
npm install -g local-ssl-proxy
Running SSL proxy
Run the proxy using the configuration file in this repo.
local-ssl-proxy --config proxy-config.json
4. Launch Chrome with --ignore-cr
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --ignore-certificate-errors &> /dev/null &
Go to https://app.squadlytics.dev:8090 and voilà!