How could I get my web App URL in Node.js? I mean if my site base url is http://localhost:8080/MyApp How could I get it?
Thanks,
You must connect 'url' module
var http = require('http');
var url = require('url') ;
http.createServer(function (req, res) {
var hostname = req.headers.host; // hostname = 'localhost:8080'
var pathname = url.parse(req.url).pathname; // pathname = '/MyApp'
console.log('http://' + hostname + pathname);
res.writeHead(200);
res.end();
}).listen(8080);