Хочу сделать редирект на с http на https?
Есть такой код:
const PORT = 8889;
const PORT_HTTPS = 3443;
const fs = require('fs');
const express = require('express');
const app = express();
const https = require('https');
const privateKey = fs.readFileSync( __dirname + '/cert/key.pem', 'utf8').toString();
const certificate = fs.readFileSync( __dirname + '/cert/server.crt', 'utf8').toString();
const credentials = {key: privateKey, cert: certificate, passphrase: ''};
const httpsServer = https.createServer(credentials, app);
app.use(express.static(__dirname + '/site'));
// Жалкая попытка редиректа
/* app.all('*', (req, res) => {
res.redirect(300, 'https://' + req.hostname + ':' + PORT_HTTPS + req.url)
}); */
app.get('/', function(req, res) {...})
//...
app.post('/', function(req, res) {...})
//...
app.listen(PORT);
httpsServer.listen(PORT_HTTPS, () => console.log('HTTPS on ' + PORT_HTTPS));
Что можно с этим сделать?