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?