从request获取完整的请求路径的问题
//router
exports.doSomething = function(req, res){ var protocol = req.protocol; var host = req.host; var path = req.path; //可是没有端口 var port = …?
//拼接
var url = protocol + "://" + host + port + path;
}
3 回复
port怎么获取呢?
port是你自己定义的啊!全局变量不就行了么
注意 req.headers.host 有包含port