Express.js- 为什么 Localhost '::'
Express.js- Why is Localhost '::'
谁能告诉我为什么我的服务器地址(主机)是 :: 而不是 localhost
var express = require('express');
var app = express();
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
res.send('hello world');
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
这个returns
Example app listening at http://:::3000
时它工作正常
因为::在使用IPv6时是localhost,就像在IPv4中是127.0.0.1一样
谁能告诉我为什么我的服务器地址(主机)是 :: 而不是 localhost
var express = require('express');
var app = express();
// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
res.send('hello world');
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
这个returns
Example app listening at http://:::3000
时它工作正常
因为::在使用IPv6时是localhost,就像在IPv4中是127.0.0.1一样