Pages

Monday, April 26, 2021

HTTPS on localhost - for React and Laravel

Generating Self-signed Certificate: (Linux - ubuntu)

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./selfsigned.key -out ./selfsigned.crt

(source)

Launching React app with the certificate/key: (Linux)

HTTPS=true SSL_CRT_FILE=./ssl/selfsigned.crt SSL_KEY_FILE=./ssl/selfsigned.key npm start

or we can set the variables in .env file

(source)

Launching Laravel on HTTPs: ( using ngrok )

after running: ( ➜ php artisan serve --host <IP_ADDRESS> )

 

 ./ngrok http <IP_ADDRESS>:<PORT>

(source) - (ngrok)