document.location.origin is not needed, and fails in IE