From 2066da95a71ecaa87c73adbf4b3188b412c88f3b Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Sun, 28 Jul 2019 17:04:09 +0200 Subject: [PATCH 1/2] All get requests for /sockjs-node* excluded from processing by http-proxy-middleware #6720 --- packages/react-dev-utils/WebpackDevServerUtils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 1d7021e037c..8d74e8cf131 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -361,10 +361,14 @@ function prepareProxy(proxy, appPublicFolder) { process.exit(1); } - // If proxy is specified, let it handle any request except for files in the public folder. + // If proxy is specified, let it handle any request except for + // files in the public folder and requests to the WebpackDevServer socket endpoint. + // https://github.com/facebook/create-react-app/issues/6720 function mayProxy(pathname) { const maybePublicPath = path.resolve(appPublicFolder, pathname.slice(1)); - return !fs.existsSync(maybePublicPath); + const isPublicFileRequest = fs.existsSync(maybePublicPath); + const isWdsEndpointRequest = pathname.startsWith('/sockjs-node'); // used by webpackHotDevClient + return !(isPublicFileRequest || isWdsEndpointRequest); } if (!/^http(s)?:\/\//.test(proxy)) { From 2059bb0798a983718065cee120f6eb16e6c9e912 Mon Sep 17 00:00:00 2001 From: Dmitry Lepskiy Date: Sun, 28 Jul 2019 17:04:09 +0200 Subject: [PATCH 2/2] All get requests for /sockjs-node* excluded from processing by http-proxy-middleware #6720 --- packages/react-dev-utils/WebpackDevServerUtils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 1d7021e037c..8d74e8cf131 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -361,10 +361,14 @@ function prepareProxy(proxy, appPublicFolder) { process.exit(1); } - // If proxy is specified, let it handle any request except for files in the public folder. + // If proxy is specified, let it handle any request except for + // files in the public folder and requests to the WebpackDevServer socket endpoint. + // https://github.com/facebook/create-react-app/issues/6720 function mayProxy(pathname) { const maybePublicPath = path.resolve(appPublicFolder, pathname.slice(1)); - return !fs.existsSync(maybePublicPath); + const isPublicFileRequest = fs.existsSync(maybePublicPath); + const isWdsEndpointRequest = pathname.startsWith('/sockjs-node'); // used by webpackHotDevClient + return !(isPublicFileRequest || isWdsEndpointRequest); } if (!/^http(s)?:\/\//.test(proxy)) {