I am trying to redirect every http request to an https server. This works fine if the port of the https server is the 443. However if I try to redirect to a different port it doesn't happen. Here is my code:
http.createServer(function(req,res){
var host = req.headers['host'],
url = req.url;
res.writeHead(301,
{"Location": "https://" + host + ":"+SERVER.SPORT + url})
res.end()
}).listen(SERVER.PORT)
https.createServer(SERVER.HTTPS_OPTIONS,app).listen(SERVER.SPORT)