xhr.open(...) with username and password works only when the script is at the same domain as the URI. This appears to be due to the so-called same origin policy. As one would note from this answer here on StackOverflow, one can send an explicit Authorization header with the xhr request, thus bypassing the same origin policy.
The question is why do we then have this same origin policy that can, with little effort, be bypassed?
Thanks in advance!