Enable https in Node.js production application using heroku

时间:2017-12-18 05:11:30

标签: node.js express heroku https socket.io

Hello I have deployed a a node.js production application using heroku. But the problem is the link generated by heroku is https but my server does not use https. Here is my server code:

var express = require('express.io');
var app = express();
app.http().io();
var PORT = 3000;
console.log('server started on port ' + PORT);

app.use(express.static(__dirname + '/public'));

app.get('/', function(req, res){
    res.render('index.ejs');
});

app.listen(process.env.PORT || PORT);

app.io.route('signal', function(req) {
    req.io.join(req.data);
    req.io.join('files');
    app.io.room(req.data).broadcast('signal', {
        user_type: req.data.user_type,
        user_name: req.data.user_name,
        user_data: req.data.user_data,
        command: req.data.command
    })
})

app.io.route('files', function(req) {
    req.io.room('files').broadcast('files', {
        filename: req.data.filename,
        filesize: req.data.filesize
    });
})

How do I modify the server code to enable https?

0 个答案:

没有答案