React JS localhost with https using mkcert

Jay (Vijayasimha BR)
2 min readAug 28, 2022

--

hey. ant eaters. they are pretty cool.

More stuff for my students in the ongoing MERN batch. This is about https. I am running of supposedly clever things to put here.

As usual, the code is available, here. httpshelloworld.

Right then. There will always be a ton of scenarios where you want to run you r React JS project with https, during local development. To do that, you need to generate your own local certificates.

Here is the full set of commands.

In my own experience, getting the certificates to work was a lot of trial and error. My assumption based on my own experience of using Mac for more than 5 years is that, the process is far simpler on the Mac, and same commands should work.

Again, it’s an assumption.

Also, remember that the browsers will complain the first time your run the code. Sure, technically speaking, there is a certificate, but this is ultimately a fake certificate.

So, you will need to click some kind of ‘accept risk’ or some similar warning, before you allow the project to run locally.

Lastly, one specific scenario where you want to do this is when you are consuming API servers which only work with https clients. Or, login systems which also demand the login requests come from https origins.

Also, it might just be easier to make all your react js projects use https, just to make it part of your regular coding habit.

and that’s about it.

I work as a full time freelance coding tutor. Hire me at UpWork or Fiverr or Stack Overflow. My personal website is here. Find more of my art at Behance and Unsplash. Also, I have a Podcast about everyday life. And, a 2nd Podcast, where I talk about freelancing.

--

--

Responses (1)