I am Hack Sparrow
Captain of the Internets.

Node.js get IP Address

Getting a user's IP address seems pretty straightforward in Node.js, right? Does it need a special post on my blog? Yes it does, we'll find out why in a few seconds. Conventional wisdom says, this is how you would get the IP address from a request: [code] var ip = req.connection.remoteAddress; [/code] But there is a problem. If you are running your app behind Nginx or any proxy, every single IP addresses will be 127.0.0.1 :D Probably you can see the problem now. So wha ...

POST / GET Request Handling in Node.js Express

URL and forms processing are two of the many factors that make the Web the dynamic and useful platform it is. Any server-side technology that is worth it's salt should implement ways to handle the HTTP GET and POST request efficiently. Let's find out how to handle GET and POST requests in the Node.js Web framework Express.js with some examples. HTML GET form: [code] <form method= ...

Using Node.js to download files

There are three approaches to writing a file downloader app using Node - i. HTTP.get, ii. curl, iii. wget. I have created functions for all of them. To get the examples working makes sure you have the dependencies and app variables intact. Read the comments thoroughly, you will not only learn how to download files, but will also learn more about Node's child_process, File System, Buffers, and Streams. Let's start with HTTP.get. ...