0

I am working on a rest api.

That api is used by my website and the website is used by various users. I want to restrict the api access only to my website ( no other website should be able to access that rest api ) so for that I want to whitelist my domain name on the basis of the ip of the domain name

My goal is to find the ip of domain name requesting my ip not the ip of the users accessing my domain.

How can I achieve it in nodejs?

Abhishek Goel
  • 18,785
  • 11
  • 87
  • 65

2 Answers2

0

See Getting HTTP headers with node.js

You should be able to use the referer data in the header to check where the request is coming from.

Community
  • 1
  • 1
MattieTK
  • 501
  • 6
  • 15
0

From your API's viewpoint the IP of the request won't really be different from a server vs. a client. Although, other than some HTTP header variables.

You could simply check all the IPs of incoming requests for your "secured" endpoint and check it against a whitelist of all your server IPs.

Personally, I'd probably use ssl between servers.

Hyo Byun
  • 1,196
  • 9
  • 18