How to redirect user's browser URL to a different page in Nodejs?
response.writeHead(301,
{Location: 'http://whateverhostthiswillbe:8675/'+newRoom}
);
response.end();
For those who (unlike OP) are using the express lib:
http.get('*',function(req,res){
res.redirect('http://exmple.com'+req.url)
})
OP: "I would love if there were a way to do it where I didn't have to know the host address..."
response.writeHead(301, {
Location: "http" + (request.socket.encrypted ? "s" : "") + "://" +
request.headers.host + newRoom
});
response.end();