Use valid HTTP headers to get req.baseUrl and port

Closes #1702.
Merge pull request #1704 from adamhooper/get-baseUrl-from-http-host

Use valid HTTP headers to get req.baseUrl and port