我们的网址中常用<base href="">来标明前面那部分,然而,nodejs express框架有这个方法吗?是不是要手动写一个拦截器?
黄舟2017-04-17 15:26:09
What are you trying to intercept? Your node express should not be a server, listening for requests. The requests are all sent to your server. Do you know your own IP and port? ? ?
const server = app.listen(3000, 'localhost', function () {
const host = server.address().address
const port = server.address().port
console.log("应用实例,访问地址为 http://%s:%s", host, port)
})
大家讲道理2017-04-17 15:26:09
var ip = req.headers['x-real-ip'] ? req.headers['x-real-ip'] : req.ip.replace(/::ffff:/, '');
The IP obtained above has been processed. You can get the IP regardless of whether you use a proxy or a direct connection.
Port. . . It seems I haven’t found a way