How do I get the full url , such as http://user:pass@host.com:8080/p/a/t/h?query=string#hash . Useing request.url can get /p/a/t/h?query=string ,but I hope to get full including #hash. What should I do?
var http = require('http');
var url = require('url');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end(request.url + '\n');
}).listen(8124);
The hash is not sent to the server. You cannot get it server-side. (At least, not without some code running client-side sending it in another request over AJAX.)
The content after "#" is a bookmark on the client side and is not part of the URL sent to the server. You may want to read about "back button" problem to understand what it means. Something related to this on SO: Detecting Back Button/Hash Change in URL.