Node.js命令行程序

Node.js也是可以写命令行程序的,与Web程序的不同之处就在于package.json的设置 需要在package.json中添加如下配置 ...

November 14, 2017

Express.js Get Client IP

Express中如果想获取客户端的IP,首先要设置trust proxy: app.set('trust proxy', 1); // or app.enable('trust proxy'); 设置完之后,就可以从req中取到IP了: var ip = req.ip; // or ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; ...

October 19, 2016