Skip to content
This repository was archived by the owner on Sep 6, 2019. It is now read-only.

Commit b4ffd28

Browse files
authored
Merge pull request #1 from habx/fix-socket
cf facebook#1588
2 parents a98c3df + 4ed9843 commit b4ffd28

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/react-dev-utils/webpackHotDevClient.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ if (module.hot && typeof module.hot.dispose === 'function') {
6161
var connection = new SockJS(
6262
url.format({
6363
protocol: window.location.protocol,
64-
hostname: window.location.hostname,
65-
port: window.location.port,
64+
hostname: process.env.HOST || window.location.hostname,
65+
port: process.env.PORT || window.location.port,
6666
// Hardcoded in WebpackDevServer
67-
pathname: '/sockjs-node',
67+
pathname: '/sockjs-node'
6868
})
6969
);
7070

packages/react-scripts/config/env.js

+6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ function getClientEnvironment(publicUrl) {
8585
// This should only be used as an escape hatch. Normally you would put
8686
// images into the `src` and `import` them in code to get their paths.
8787
PUBLIC_URL: publicUrl,
88+
89+
// Useful for allowing the hot dev websocket to connect to the host
90+
// specified in the env file, instead of window.location, which could
91+
// be wrong if the dev server is being proxied.
92+
HOST: process.env.HOST || '',
93+
PORT: process.env.PORT || ''
8894
}
8995
);
9096
// Stringify all values so we can feed into Webpack DefinePlugin

0 commit comments

Comments
 (0)