diff --git a/src/builtins/hmr-runtime.js b/src/builtins/hmr-runtime.js index 6a0589488d4..30e90ec1217 100644 --- a/src/builtins/hmr-runtime.js +++ b/src/builtins/hmr-runtime.js @@ -15,7 +15,7 @@ function Module() { module.bundle.Module = Module; if (!module.bundle.parent && typeof WebSocket !== 'undefined') { - var ws = new WebSocket('ws://localhost:{{HMR_PORT}}/'); + var ws = new WebSocket('ws://' + window.location.hostname + ':{{HMR_PORT}}/'); ws.onmessage = function(event) { var data = JSON.parse(event.data); diff --git a/test/utils.js b/test/utils.js index de6212580af..ffdf0b37e73 100644 --- a/test/utils.js +++ b/test/utils.js @@ -78,11 +78,14 @@ function run(bundle, globals) { { document: fakeDocument, WebSocket, - console + console, + location: {hostname: 'localhost'} }, globals ); + ctx.window = ctx; + vm.createContext(ctx); vm.runInContext(fs.readFileSync(bundle.name), ctx); return ctx.require(bundle.entryAsset.id);