Skip to content

Commit e3732bb

Browse files
committed
XDomainRequest must always be protocol relative (cant http -> https)
1 parent eeb87d5 commit e3732bb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/raven.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ Raven.prototype = {
909909
_makeXhrRequest: function(opts) {
910910
var request;
911911

912+
var url = opts.url;
912913
function handler() {
913914
if (request.status === 200) {
914915
if (opts.onSuccess) {
@@ -929,13 +930,17 @@ Raven.prototype = {
929930
};
930931
} else {
931932
request = new XDomainRequest();
933+
// xdomainrequest cannot go http -> https (or vice versa),
934+
// so always use protocol relative
935+
url = url.replace(/^https?:/, '');
936+
932937
// onreadystatechange not supported by XDomainRequest
933938
request.onload = handler;
934939
}
935940

936941
// NOTE: auth is intentionally sent as part of query string (NOT as custom
937942
// HTTP header) so as to avoid preflight CORS requests
938-
request.open('POST', opts.url + '?' + urlencode(opts.auth));
943+
request.open('POST', url + '?' + urlencode(opts.auth));
939944
request.send(JSON.stringify(opts.data));
940945
},
941946

0 commit comments

Comments
 (0)