I want to get the url the client has requested out of the request.
Currently I use:
var requestedUrl = req.protocol + \'://\' + req.host + \':3000\' + re
You cannot get the fragment (hash section) of a url on the server, it does not get transmitted by the browser.
The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server — of course the server typically helps to determine the MIME type, and the MIME type determines the processing of fragments. When an agent (such as a Web browser) requests a resource from a Web server, the agent sends the URI to the server, but does not send the fragment. Instead, the agent waits for the server to send the resource, and then the agent processes the resource according to the document type and fragment value.
From Fragment Identifier on Wikipedia
If you want to get the complete URL (without the fragement identifier), the best way would be to use the "Host" header which includes the port rather than req.host but otherwise the same as you are currently doing:
var requestedUrl = req.protocol + '://' + req.get('Host') + req.url;