How To Certified LocalURL in React JS

In this article, we will learn how to certify your localurl using mkcert in React.js.

Here, If you open your locally running site in your browser using HTTPS, your browser will check the certificate of your local development server.

Upon seeing that the certificate has been signed by the mkcert-generated certificate authority, the browser checks whether it’s registered as a trusted certificate authority.

Mkcert is specialized in creating certificates that are compliant with what browsers consider valid certificates.

Following steps follow to create mkcert,

  1. Install mkcert
    |chocoinstall mkcert
  2. Add mkcert to your local root CA(certificate authority)s.
    mkcert -install
  3. Generate a certificate for your site, signed by mkcert.
    mkcert localhost
  4. Start your server as follows:
    "scripts": {
    "start": "HTTPS=true SSL_CRT_FILE={PATH/TO/CERTIFICATE-FILENAME}.pem SSL_KEY_FILE={PATH/TO/CERTIFICATE-KEY-FILENAME}.pem react-scripts start"
    }

    For example, if you’ve created a certificate for localhost that is located in your site’s root directory as follows:

    |-- my-react-app
        |-- package.json
        |-- localhost.pem
        |-- localhost-key.pem
        |--...

    Then your start script should look like this:

    "scripts": {
        "start": "HTTPS=true SSL_CRT_FILE=localhost.pem SSL_KEY_FILE=localhost-key.pem react-scripts start"
    }

You can see below without certified and certified your localurl,

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe

Select Categories