Skip to content

Commit c9a12c6

Browse files
author
ncruz
committed
commit reference from facebook#1588
1 parent 00b5fa9 commit c9a12c6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/react-dev-utils/webpackHotDevClient.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ 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: window.location.hostname,
65+
// port: window.location.port,
66+
// https://github.com/facebook/create-react-app/pull/1588/commits/532b4636716b3006d848683131f96395e546fc1e
67+
hostname: process.env.HOST || window.location.hostname,
68+
port: process.env.PORT || window.location.port,
6669
// Hardcoded in WebpackDevServer
6770
pathname: '/sockjs-node',
6871
})

packages/react-scripts/config/env.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ 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+
// Useful for allowing the hot dev websocket to connect to the host
89+
// specified in the env file, instead of window.location, which could
90+
// be wrong if the dev server is being proxied.
91+
'HOST': process.env.HOST || '',
92+
'PORT': process.env.PORT || ''
8893
}
8994
);
9095
// Stringify all values so we can feed into Webpack DefinePlugin

0 commit comments

Comments
 (0)