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) {