21
Run creat-react-app with HTTPS
In current days we host websites on Vercel and Netlify and we are automatically assigned a generated SSL to provide with Secured connection(HTTPS), but in the development period we are unaware of the process to run it with HTTPS and we miss out on some testing which works only on HTTPS like google apis, etc.
Add a file
.env
in the root directory of the project with the lineHTTPS=true
Follow this article to generate a SSL certificate for localhost. and place the certificates in the root directory.
after following this article you must have 8 new files in your directory, which are
rootCA.key
rootCA.pem
rootCA.srl
server.crt
server.csr
server.csr.cnf
server.key
v3.ext
in the
.env
file add these two properties and there paths.SSL_CRT_FILE=server.crt
SSL_KEY_FILE=server.key
Here you will be using the
server.crt
as your certificate file & server.key
as your key for certificate.If you're stuck anywhere do leave a comment.
Happy Hacking!
21