Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js - How to set up a server on my local machine and allow someone to access it(for testing)

I am writing a node.js app and need to get a friend to help test it for me(at a different location). Can I set something up on my local machine to allow him to access it? I tried Googling but found little help.

Could someone please tell me how? I realize this is a terrible idea for production purposes, but I'm only planning on using it for testing as the budget for this project is a little tight.

Any help is appreciated!

like image 888
starscape Avatar asked Mar 01 '13 19:03

starscape


1 Answers

First of all you should bind your node http(s) server to your public IP, for example:

var http = require("http");
// ...
http.createServer(function(req, res) {
    // ...
}).listen(PORT, null); // passing null or nothing as the second argument, will bind the http server to all interfaces.

Next, if you're behind a router/firewall you should add a route to your computer (on your local network) on the port that your node server is listening on.

Also you should have a static IP address or use dynamic DNS, so your friend will be able to reach your computer.

like image 135
fardjad Avatar answered Sep 22 '22 23:09

fardjad