Nodejs Express模块server.address().address为::


来自 http://blog.csdn.net/medivhq/article/details/74171939

我按照菜鸟教程上的写法为:(http://www.runoob.com/nodejs/nodejs-express-framework.html)

var server = app.listen(8081,function () {
    var host = server.address().address
    var port = server.address().port
    console.log("应用实例,访问地址为 http://%s:%s", host, port)
})

打印结果: 
应用实例,访问地址为 http://:::8081 
修改方法,自定义locahost即可:

var server = app.listen(8081,'localhost',function () {
    var host = server.address().address
    var port = server.address().port
    console.log("应用实例,访问地址为 http://%s:%s", host, port)

})

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM