title: Node.js Express: handle requests when users search for .html files directly
body: <p>I'm having trouble handling requests where a user requests the URL of an HTML file. For example, if the user searches localhost:8080/profile - it will redirect them to a login page if they aren't logged in, however if they search for localost:8080/profile.html it will always take them to profile.html. 
  I essentially want to be able to handle requests when they search directly for HTML files. 
  When I try to handle using express with:</p>
  
  <pre><code>app.get("/profile", function(req, res) {
      // Handle req here
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>app.get("/profile.html", function(req, res) {
      // Handle req here
  }
  </code></pre>
  
  <p>neither of these are called when the user searches /profile.html.</p>
  
  <p>All html pages are stored in /public/ and below is the code relating to the setup of the express server.</p>
  
  <pre><code>let express = require("express");
  let https = require("https");
  let path = require("path");
  const bodyParser = require('body-parser');
  
  let fs2 = require("fs");
  let httpsOptions = {
      cert : fs2.readFileSync(path.join(__dirname, 'SSL', 'server.cert')),
      key : fs2.readFileSync(path.join(__dirname, 'SSL', 'server.key'))
  }
  
  let port = 3443;
  let root = "./public"
  
  let server = express();
  server.use(bodyParser.json());
  server.use(session({secret:"qwertyuiop", resave:false, saveUninitialized:true}));
  var staticPath = path.join(__dirname, '/public');
  server.use(express.static(staticPath));
  
  start();
  
  async function start() {
      try {
          https.createServer(httpsOptions, server).listen(port, function() {
              console.log('[SERVER] STATUS: Express HTTPS server on listening on port 3443');
          });
  
      }
      catch (err) { console.log(err); process.exit(1); }
  }
  </code></pre>