我使用ipInfo在我的Meteor应用程序上获取用户ip。在本地开发中,ipInfo返回良好的数据:我的ip。
但是在我的生产服务器上,ipInfo从我的服务器而不是ip客户端返回ip:
import { HTTP } from 'meteor/http';
Meteor.methods({
getIp: function() {
let request = Meteor.wrapAsync(HTTP.get),
result = request('http://ipinfo.io');
console.log(result); // Good on local, but only server IP on production
return result;
}
});有人能帮我吗?
发布于 2016-11-21 09:19:39
首先,您必须从客户端调用ipInfo。
如果你想从server...well打电话.使用onConnection函数获取客户端IP,当询问ipInfo时
如果您从客户端调用服务器端方法,也可以使用this.connection.clientAddress .
https://stackoverflow.com/questions/40716349
复制相似问题