How to get the current url in node js ? I have following code but it doesn't work properly.
var http = require("http");
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
console.log(request.headers.host);
response.end();
}
http.createServer(onRequest).listen(3000);
Apache redirecting localhost:3000 to node.dev domain. When I run above code I have: localhost:3000 but I want to node.dev (with subdomain, all url)
Ok, I have found the solution:
request.headers['x-forwarded-host']