From 72ba7505aff2a8314e82aa5082379a77504a1fcb Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sat, 7 Sep 2019 13:02:34 +0800 Subject: [PATCH] fix: should not proxy sockjs endpoint (#4550) fixes #4504 thanks to https://github.com/facebook/create-react-app/pull/7444 --- packages/@vue/cli-service/lib/util/prepareProxy.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli-service/lib/util/prepareProxy.js b/packages/@vue/cli-service/lib/util/prepareProxy.js index 6221fe336c..0b525d7487 100644 --- a/packages/@vue/cli-service/lib/util/prepareProxy.js +++ b/packages/@vue/cli-service/lib/util/prepareProxy.js @@ -44,10 +44,14 @@ module.exports = function prepareProxy (proxy, appPublicFolder) { process.exit(1) } - // Otherwise, if proxy is specified, we will 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) } function createProxyEntry (target, usersOnProxyReq, context) {