https 模块无法在我的本地主机上工作。我已经经历过这个blog.mgechev.com教程。我的 Node v5.10.1。
这里的代码:
//index.js
var fs = require('fs'),
https = require('https'),
express = require('express'),
app = express();
https.createServer({
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
}, app).listen(55555);
app.get('/', function (req, res) {
res.header('Content-type', 'text/html');
return res.end('<h1>Hello, Secure World!</h1>');
});
node index.js
输出:
最佳答案
这是一个愚蠢的错误。我只是用前面的 https
点击 url,它工作正常。
即:-
https://localhost:55555
关于node.js - https ssl/tls 无法在 Nodejs 中的 localhost 上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36497425/