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 f6ec4aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/main.js
Expand Up @@ -74,7 +74,7 @@ function SockJS(url, protocols, options) {
throw new SyntaxError("The URL's scheme must be either 'http:' or 'https:'. '" + parsedUrl.protocol + "' is not allowed.");
}

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

0 comments on commit f6ec4aa

Please sign in to comment.