title: How to connect React Front end to Node backend with tls/https
body: <p>I created a server that is set up with https below sample:</p>
  <pre><code>const express = require(&quot;express&quot;);
  const fs = require(&quot;fs&quot;);
  const https = require(&quot;https&quot;);
  
  const app = express();
  const port = process.env.PORT || 8000;
  
  var options = {
      key: fs.readFileSync(&quot;server.key&quot;),
      cert: fs.readFileSync(&quot;server.cert&quot;),
  };
  
  
  app.listen(port);
  https.createServer(options, app).listen(8080, function () {
      console.log(
          &quot;Example app listening on port 8080! Go to https://localhost:8080/&quot;
      );
  });
  </code></pre>
  <p>this works fine, but I am not sure how to configure React to make proper handshake. I want to secure both as I want to be able to send files from front to back end securely.
  I tried setting script in package.json to</p>
  <pre><code>&quot;start&quot;: &quot;set HTTPS=true&amp;&amp;set SSL_CRT_FILE=server.cert&amp;&amp;set SSL_KEY_FILE=server.key&amp;&amp;react-scripts start&quot;
  </code></pre>
  <p>where I copied .cert and .key that I generated for backend. But as I understood I need to set up different ones locally. <a href="https://medium.com/@danielgwilson/https-and-create-react-app-3a30ed31c904" rel="nofollow noreferrer">https://medium.com/@danielgwilson/https-and-create-react-app-3a30ed31c904</a>
  I probably misunderstood something about TLS/HTTPS</p>