Skip to content

Commit 70671ff

Browse files
oskarerSpaceK33z
authored andcommitted
Fix for web worker support (#632)
1 parent cb1b32f commit 70671ff

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

client/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,24 @@ if(urlParts.hostname === "0.0.0.0") {
9595
// why do we need this check?
9696
// hostname n/a for file protocol (example, when using electron, ionic)
9797
// see: https://github.com/webpack/webpack-dev-server/pull/384
98-
if(window.location.hostname && !!~window.location.protocol.indexOf("http")) {
99-
hostname = window.location.hostname;
98+
if(self.location.hostname && !!~self.location.protocol.indexOf("http")) {
99+
hostname = self.location.hostname;
100100
}
101101
}
102102

103103
// `hostname` can be empty when the script path is relative. In that case, specifying
104104
// a protocol would result in an invalid URL.
105105
// When https is used in the app, secure websockets are always necessary
106106
// because the browser doesn't accept non-secure websockets.
107-
if(hostname && (window.location.protocol === "https:" || urlParts.hostname === "0.0.0.0")) {
108-
protocol = window.location.protocol;
107+
if(hostname && (self.location.protocol === "https:" || urlParts.hostname === "0.0.0.0")) {
108+
protocol = self.location.protocol;
109109
}
110110

111111
var socketUrl = url.format({
112112
protocol: protocol,
113113
auth: urlParts.auth,
114114
hostname: hostname,
115-
port: (urlParts.port === "0") ? window.location.port : urlParts.port,
115+
port: (urlParts.port === "0") ? self.location.port : urlParts.port,
116116
pathname: urlParts.path == null || urlParts.path === "/" ? "/sockjs-node" : urlParts.path
117117
});
118118

@@ -123,12 +123,12 @@ function reloadApp() {
123123
log("info", "[WDS] App hot update...");
124124
var hotEmitter = require("webpack/hot/emitter");
125125
hotEmitter.emit("webpackHotUpdate", currentHash);
126-
if(typeof window !== "undefined") {
126+
if(typeof self !== "undefined") {
127127
// broadcast update to window
128-
window.postMessage("webpackHotUpdate" + currentHash, "*");
128+
self.postMessage("webpackHotUpdate" + currentHash, "*");
129129
}
130130
} else {
131131
log("info", "[WDS] App updated. Reloading...");
132-
window.location.reload();
132+
self.location.reload();
133133
}
134134
}

0 commit comments

Comments
 (0)