Skip to content

Instantly share code, notes, and snippets.

@jdavisclark
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save jdavisclark/4fe652a143314be98e29 to your computer and use it in GitHub Desktop.

Select an option

Save jdavisclark/4fe652a143314be98e29 to your computer and use it in GitHub Desktop.
basic console echoing debug server with built in localtunnel. need to install localtunnel
// if you want to specify a custom localtunnel subomain, just throw it in an additional argument eg: node debugWebserver.js mysubdomain
var util = require("util");
var lt = require("localtunnel");
var http = require('http');
http.createServer(function (req, res) {
console.log(req.method + " " + req.url)
req.on("data", function(chunk) {
console.log("Body: " + chunk)
});
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('');
}).listen(1337, '0.0.0.0');
var tunnel = lt(1337, {
subdomain: process.argv[2]
}, function(err, tunnel) {
if (err) {
console.log("error starting tunnel: " + err);
process.exit(1);
}
console.log(tunnel.url)
});
process.on("exit", function() {
tunnel.close();
console.log("closing tunnel..");
})
process.on("SIGINT", function() {
tunnel.close();
process.exit();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment