To enable create react app to run in SSL mode, we need to set HTTPS=true in the package.json like this
"start": "HTTPS=true react-scripts start",
However, I would like this only in production and not when development happens locally. I have a .env file, and would like to use a flag REACT_APP_USE_SSL=true in production and then REACT_APP_USE_SSL=false locally.
My question is, how can I use this environment variable in package.json? Or is there another way to seamlessly switch between HTTP and HTTPS mode for development and production environment?
As mentioned in the comment by @kiranvj, (and also after the reading the doc myself), this is easier than the other complicated solutions I was trying to implement.
You can just set HTTPS=true or HTTPS=false in your .env file and create react app will pick it up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With