Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Only allow CORS when we have a document.domain to prevent Origi…
…n:null. Fixes #281
- Loading branch information
Showing
2 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/transformers/sockjs/library.js b/transformers/sockjs/library.js | ||
index 7666a55..095fa29 100644 | ||
--- a/transformers/sockjs/library.js | ||
+++ b/transformers/sockjs/library.js | ||
@@ -922,12 +922,14 @@ XDRObject.prototype.close = function() { | ||
// 3. Nope, but postMessage is there so it should work via the Iframe. | ||
// 4. Nope, sorry. | ||
utils.isXHRCorsCapable = function() { | ||
- if (_window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()) { | ||
- return 1; | ||
- } | ||
- // XDomainRequest doesn't work if page is served from file:// | ||
- if (_window.XDomainRequest && _document.domain) { | ||
- return 2; | ||
+ // CORS doesn't work if page is served from file:// | ||
+ if (_document.domain) { | ||
+ if (_window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()) { | ||
+ return 1; | ||
+ } | ||
+ if (_window.XDomainRequest) { | ||
+ return 2; | ||
+ } | ||
} | ||
if (IframeTransport.enabled()) { | ||
return 3; |