在Express 4.x中启动HTTPS

时间:2014-05-07 19:42:29

标签: node.js express

我正在尝试使用Express 4.x在HTTPS中启动服务器。我试过了

  var credentials = {key: privateKey, cert: certificate};
  var app = express(credentials);

但它不起作用。

1 个答案:

答案 0 :(得分:14)

您可以轻松地执行以下操作:

var app = express(),
    credentials = {key: privateKey, cert: certificate},
    server = https.createServer(credentials, app);
server.listen(8443);