Check for host first

Host isn’t always present and will throw a notice, causing ajax calls
to be broken