使用 https with express

首先,你必須使用 OpenSSL( 教程 ) 生成公鑰和私鑰。

var express = require("express");
var http =require ("http"); 
var https=require ("https");
var fs=require("fs");
var app=express();
var httpsKeys={
key:fs.readFileSync("<key.pem>");
crtifcte:fs.readFileSync("<certificate.pem>");
};
http.createserver(app).listen(3000);
https.createserver(httpsKeys,app).listen(3030);