Skip to content

Commit

Permalink
fix: allow accessing http://127.0.0.1 from https page
Browse files Browse the repository at this point in the history
... since 127.0.0.1 is [potentially trustworthy](https://www.w3.org/TR/secure-contexts/#is-origin-trustworthy) and honored by most browsers (chromium & firefox)
  • Loading branch information
cyjake committed Jun 8, 2020
1 parent 3ccf61d commit e157b91
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/main.js
Expand Up @@ -76,7 +76,7 @@ function SockJS(url, protocols, options) {

var secure = parsedUrl.protocol === 'https:';
// Step 2 - don't allow secure origin with an insecure protocol
if (loc.protocol === 'https:' && !secure) {
if (loc.protocol === 'https:' && !secure && parsedUrl.host !== '127.0.0.1') {
throw new Error('SecurityError: An insecure SockJS connection may not be initiated from a page loaded over HTTPS');
}

Expand Down

0 comments on commit e157b91

Please sign in to comment.