Skip to content

Instantly share code, notes, and snippets.

@sumitsahoo
Last active October 14, 2024 14:15
Show Gist options
  • Save sumitsahoo/35d97353b977aa48de18e1959c72ba86 to your computer and use it in GitHub Desktop.
Save sumitsahoo/35d97353b977aa48de18e1959c72ba86 to your computer and use it in GitHub Desktop.
Run react app as HTTPS localhost

Make sure openssl is installed

brew install openssl

Generate cert and key

openssl req -x509 -newkey rsa:4096 -keyout cert.key -out cert.crt -sha256 -days 3650 -nodes -subj "/C=XX/ST=YOUR_STATE/L=YOUR_LOCATION/O=YOUR_COMPANY/OU=YOUR_ORG/CN=YOUR_DOMAIN"

Replace the values with yours

Update script

Now modify the run script to

HTTPS=true SSL_CRT_FILE=cert.crt SSL_KEY_FILE=cert.key react-scripts start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment