I'm trying to deploy a Node.js app on Heroku using express, and I am struggling to enforce HTTPS on all incoming traffic. I am using the express-sslify library to do this using the code below, which is identical to the express-sslify docs, but the website still accepts non-HTTPS traffic. Any advice on what to correct and/or alternative middleware to use would be greatly appreciated!
server.js file
var history = require('connect-history-api-fallback');
var enforce = require('express-sslify');
var http = require('http');
var express = require('express');
var serveStatic = require("serve-static")
var path = require('path');
var app = express();
app.use(enforce.HTTPS({ trustProtoHeader: true }));
app.use(serveStatic(path.join(__dirname, 'dist')));
app.use(history());
const port = process.env.PORT || 80;
http.createServer(app).listen(port)