Skip to content

Commit

Permalink
fix hostname resolving when using something like Electron (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
svsool authored and SpaceK33z committed Sep 6, 2016
1 parent 02db200 commit 717880f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,21 @@ var onSocketMsg = {
}
};

var hostname = urlParts.hostname;

if(urlParts.hostname === '0.0.0.0') {
// why do we need this check?
// hostname n/a for file protocol (example, when using electron, ionic)
// see: https://github.com/webpack/webpack-dev-server/pull/384
if(window.location.hostname && !!~window.location.protocol.indexOf('http')) {
hostname = window.location.hostname;
}
}

var socketUrl = url.format({
protocol: (window.location.protocol === "https:" || urlParts.hostname === '0.0.0.0') ? window.location.protocol : urlParts.protocol,
auth: urlParts.auth,
hostname: (urlParts.hostname === '0.0.0.0') ? window.location.hostname : urlParts.hostname,
hostname: hostname,
port: (urlParts.port === '0') ? window.location.port : urlParts.port,
pathname: urlParts.path == null || urlParts.path === '/' ? "/sockjs-node" : urlParts.path
});
Expand Down

0 comments on commit 717880f

Please sign in to comment.