title: Mixed content error for http express route
body: <p>I'm running a local node js server on my machine and I provide it with a <code>ngrok.io</code> domain.</p>
  
  <p>If I run it local in the web browser with <code>localhost:3000</code> or with <code>http://1234.ngrok.io</code> everything is ok. If I call it with <code>httpS://1234.ngrok.io</code> I get the error</p>
  
  <pre><code>Mixed Content: The page at 'https://1234.ngrok.io/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:3000/calculation'. This request has been blocked; the content must be served over HTTPS.
  </code></pre>
  
  <p>caused because the route is not http. How can I fix this?</p>
  
  <p>This is the app.js on my node.js</p>
  
  <pre><code>const express = require('express');
  const app = express();
  const https = require('https');
  const http = require('http');
  const fs = require('fs');
  
  app.use('/', express.static(__dirname + '/../Client'));
  
  var options = {
    key: fs.readFileSync('./https_certificate/client-key.pem'),
    cert: fs.readFileSync('./https_certificate/client-cert.pem')
  };
  
  app.listen(server_connection.port, () =&gt; {
      console.log('Server started on port ' + server_connection.port);
      //do stuff
  });
  
  //load the index.html from the server
  app.get('/', function(req, res) {
      res.sendFile(path.join(__dirname + '/../Client/index.html'));
  });
  </code></pre>
  
  <p>This is the other file with the route who causes the error:</p>
  
  <pre><code>const express = require('express');
  const router = express();
  router.post('/calculation', function(req, res) {
   //do stuff
  }
  </code></pre>
  
  <p>I already tried to configure the server for https how you can see on the <code>options</code> object in the first file but this resolved in a 502 Bad Gateway.</p>
  
  <p>I also would like to use just https. Is it possible to redirect to https if someone uses http?</p>