我有一个locomotive.js MVC项目,它在HTTP上侦听。 我想在https上收听,并将所有http重定向到https。locomotive.js听http和https
我找不到的node.js的createServer,我找到的唯一的代码是:下/lib/node_modules/locomotive/lib/locomotive/cli/server.js
console.log('booting app at %s in %s environment', dir, env);
locomotive.boot(dir, env, function(err, server) {
if (err) {
throw err;
}
server.listen(port, address, function() {
var addr = this.address();
console.log('listening on %s:%d', addr.address, addr.port, addr);
});
});
改为:
console.log('booting app at %s in %s environment', dir, env);
var crypto = require('crypto'),
fs = require("fs");
var privateKey = fs.readFileSync('/privatekey.pem').toString();
var certificate = fs.readFileSync('/certificate.pem').toString();
var https = require('https');
var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
和我有点卡住了,有什么帮助吗?
谢谢!