diff --git a/packages/runtimes/hmr/src/HMRRuntime.js b/packages/runtimes/hmr/src/HMRRuntime.js index d02a11b5803..93295befae0 100644 --- a/packages/runtimes/hmr/src/HMRRuntime.js +++ b/packages/runtimes/hmr/src/HMRRuntime.js @@ -21,7 +21,14 @@ export default (new Runtime({ filePath: __filename, code: `var HMR_HOST = ${JSON.stringify(host != null ? host : null)};` + - `var HMR_PORT = ${JSON.stringify(port != null ? port : null)};` + + `var HMR_PORT = ${JSON.stringify( + port != null && + // Default to the HTTP port in the browser, only override + // in watch mode or if hmr port != serve port + (!options.serveOptions || options.serveOptions.port !== port) + ? port + : null, + )};` + `var HMR_SECURE = ${JSON.stringify( !!(options.serveOptions && options.serveOptions.https), )};` +