certbotcertbot-external-authcertbot-dns-plugin

Enable SSL for a React Hosted App using npm serve


I have hosted my react app on google Cloud server (ubuntu 18.04 LTS) and associated my domain with that as well. I am trying to use certbot to SSL my website for free but unfortunately, everywhere I see it has tutorial for setting it up using nginx or apache. To serve my app I have used the simple commands:

sudo npm run build
sudo serve -s build --listen 80

Now I am struggling a bit to setup ssl for my react app, has anyone tried the same before?


Solution

  • If you have your certificate files I mean key.pem and certificate.cert you can start serve as below.

    serve --ssl-cert /dir/to/certificate.crt --ssl-key /dir/to/key.pem  -s build -l 80