Hi feathers,
Is it possible to access the remote_address in the before hook and if so, how is it done?
Best regards
Patrick
You can add a middleware and set the req.feathers object with that information:
app.use(function(req, res, next) {
req.feathers.ip = req.ip;
next();
});
Now it will be available for every REST call in the service parameters as params.ip. For websocket connections you will have to do the same thing in a Socket.io middleware.
Brilliant, thanks!
Glad to help. Closing.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.
Up to date documentation can be found at: https://docs.feathersjs.com/faq/readme.html#how-do-i-access-the-request-object-in-hooks-or-services
https://docs.feathersjs.com/api/express.html#params
https://docs.feathersjs.com/api/socketio.html#appconfiguresocketiocallback
Most helpful comment
You can add a middleware and set the
req.feathersobject with that information:Now it will be available for every REST call in the service parameters as
params.ip. For websocket connections you will have to do the same thing in a Socket.io middleware.