如何使用expressjs获取https服务器地址和端口?
使用http:
var server = app.listen(3000, "127.0.0.1", function () {
var host = server.address().address;
var port = server.address().port;
console.log(server.address());
console.log('Example app listening at http://%s:%s', host, port);
});
结果:
{address:'127.0.0.1',family:'IPv4',port:3000}示例应用 在http://127.0.0.1:3000
听
但是使用https:
https.createServer(options, app).listen(3000, "127.0.0.1", function () {
console.log('Started!');
var host = https.address;
var port = https.port;
console.log('Example app listening at http://%s:%s', host, port);
});
结果:
Example app listening at http://undefined:undefined
有什么想法吗?
答案 0 :(得分:-1)