I have created a API application using meteor framework and i am using simple:json-routes package for routing. is there any way to check the IP address of client (from request) ? how to check clients IP address on simple:json-routes package? Thanks in advance.
const parseIp = (req) =>
(typeof req.headers['x-forwarded-for'] === 'string'
&& req.headers['x-forwarded-for'].split(',').shift())
|| req.connection?.remoteAddress
|| req.socket?.remoteAddress
|| req.connection?.socket?.remoteAddress
const ipAddress = parseIp(req);
Based on this answer in SO.
1 Like
Thank you @peterfkruger i am using a middleware function for check the ip address, but the req object is empty in my middleware function.
Can you paste your code here please.
1 Like
i have changed my code to–
JsonRoutes.Middleware.use(function (request,
from–
JsonRoutes.Middleware.use(function (req,
and now its working thank you very much