Despite much reading on this, I’ve found this to be an elusive task to complete. I want my React app to launch locally using SSL with a certificate that I created.
I built a small React app using version 18.2.0 (using create-react-app)
I created a pfx certificate for my machine and ran the following commands to generate crt and key files:
winpty openssl pkcs12 -in "MyPC TLS.pfx" -nocerts -out mypctls.key
winpty openssl pkcs12 -in "MyPC TLS.pfx" -clcerts -nokeys -out mypctls.crt
I then changed the commands in the Package.json
to look like this, after copying those key/crt files to the same directory as Package.json
:
"scripts": {
"start": "react-scripts start",
"startwithssl": "set HTTPS=true && set SSL_CRT_FILE=goliathtls.crt && set SSL_KEY_FILE=goliathtls.key && npm start",
},
Running npm run startwithssl
starts the app, but it continues to start the server on http.
Nothing changes if I add the following to Package.json
:
"homepage": "https://localhost:3000"
That’s kinda exhausted all the suggestions and things I’ve seen in the doco.
Have I missed a step?