Frage

Can I access the inbuilt navigator functions like isinNet() or DomainNameorHost() from nodejs?

War es hilfreich?

Lösung

Since nodeJS runs on the server, not the browser, you can't access functions that are only provided in a browser.

Most developers use a middleware like Express to create a web service on nodejs.

In a route, such as

app.route("/play", function(req,res){
   // code that handles URL /play
});

there is a callback function that is called when a request arrives for that route.

The req object parameter contains everything about the request.

req.ip is the upstream (incoming) ip address.

I looked around in npm for a module that might map remote ips to hostnames and could not find one. Presumably all it would do is reverseDNS, which could take time and hold up processing requests.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top