Closed alaycock closed 6 years ago
@alaycock what kind of use case were you looking at for this?
My use case is that I want to detect the IP through the application headers if the header exists. But there's a chance the header won't exist, and if it doesn't, I'd like to fall back to the default implementation.
After giving it a bit more thought, I realized it probably makes more sense to export getClientIp
from the package than to include it in the function call to detectIp
.
Did you have thoughts on a preferred approach, if it's necessary at all?
This is very useful for scenarios where we're behind a reverse proxy. Example: http://expressjs.com/en/guide/behind-proxies.html
Thanks for commenting on this @pdefreitas, my solution probably isn't the best option. A better solution might be to export the getClientIp
function, rather than passing it in as a function argument. Perhaps a project contributor could chime in, but I'm going to close this PR in favour of someone else creating a PR to export it instead.
My intention is to allow custom detectIp functions to fallback or build on the default implementation if they need to.
I included my yarn.lock, if you prefer not to use it, I can pull it out.