i have the following code :
var https = require('https');
var http = require('http');
var express = require('express');
var app = express();
var router = express.Router();
app.use('/', router);
//listen server on https
var server = https.createServer(config.sslCredential, app);
server.listen(config.serverPort);
//listen server on http, and always redirect to https
var httpServer = http.createServer(function(req,res){
res.redirect(config.serverDomain+req.url);
});
httpServer.listen(config.httpServerPort);
but somehow i can't get https request to be redirected into https request, how should i do this correctly on node.js with express 4.x ?