Skip to content

Commit

Permalink
Added redirection for SSL.
Browse files Browse the repository at this point in the history
  • Loading branch information
icarito committed Apr 11, 2017
1 parent a362332 commit 061d1f2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ var ioOptions = {
transports: ['WebSocket', 'AJAX long-polling']
};

/////// SSL added 20160721 by icarito

var https = require('https');
var fs = require('fs');

Expand All @@ -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());
Expand Down

0 comments on commit 061d1f2

Please sign in to comment.