diff --git a/app.js b/app.js index dd3c4d6..e2abf07 100644 --- a/app.js +++ b/app.js @@ -37,8 +37,6 @@ var ioOptions = { transports: ['WebSocket', 'AJAX long-polling'] }; -/////// SSL added 20160721 by icarito - var https = require('https'); var fs = require('fs'); @@ -50,15 +48,25 @@ var options = { var sserver = https.createServer(options, app); -//////// var io = require('socket.io', ioOptions).listen(server, {log: false}); var sio = require('socket.io', ioOptions).listen(sserver, {log: false}); +//var io = require('socket.io', ioOptions).listen(server); +//var sio = require('socket.io', ioOptions).listen(sserver); // all environments app.set('port', process.env.PORT || 80); //app.set('port', process.env.PORT || 8001); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); + +app.use(function(req,res,next) { + if (!/https/.test(req.protocol)){ + res.redirect("https://" + req.headers.host + req.url); + } else { + return next(); + } +}); + app.use(express.favicon(__dirname + '/public/images/favicon.ico')); app.use(express.logger('dev')); app.use(express.json());