2

I have a REST Api developed using MEAN stack. Everything works fine but now I need to limit the access to specific endpoints to specific IP addresses. For example, I have the following endpoints:

/api/balance
/api/account
/api/register
/api/user/details //<-- this one I want to limit access only by ip xxx.xxx.xxx.xxx (or list of ips)

My first thought is to create a middleware to intercept all requests, check if the endpoint access is limited and the origin IP and decide what to do.

There's a better solution or a proper way to do this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • https://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-in-node – euvl Aug 09 '17 at 21:41
  • 1
    Sounds perfectly valid approach to me. The other option would be having a layer in front of your web app e.g. firewall, which avoids having to embed network security in your app. – James Jan 26 '19 at 13:41

0 Answers0