Use hostname instead of host when connecting to endpoint in XHR

Fixes #195