Skip to content

Commit 7554764

Browse files
committed
fix: should not proxy sockjs endpoint (#4550)
fixes #4504 thanks to facebook/create-react-app#7444 (cherry picked from commit 72ba750)
1 parent 9b06c25 commit 7554764

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/@vue/cli-service/lib/util/prepareProxy.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
4444
process.exit(1)
4545
}
4646

47-
// Otherwise, if proxy is specified, we will let it handle any request except for files in the public folder.
47+
// If proxy is specified, let it handle any request except for
48+
// files in the public folder and requests to the WebpackDevServer socket endpoint.
49+
// https://github.com/facebook/create-react-app/issues/6720
4850
function mayProxy (pathname) {
4951
const maybePublicPath = path.resolve(appPublicFolder, pathname.slice(1))
50-
return !fs.existsSync(maybePublicPath)
52+
const isPublicFileRequest = fs.existsSync(maybePublicPath)
53+
const isWdsEndpointRequest = pathname.startsWith('/sockjs-node') // used by webpackHotDevClient
54+
return !(isPublicFileRequest || isWdsEndpointRequest)
5155
}
5256

5357
function createProxyEntry (target, usersOnProxyReq, context) {

0 commit comments

Comments
 (0)