Skip to content

Commit

Permalink
fix: should not proxy sockjs endpoint (#4550)
Browse files Browse the repository at this point in the history
  • Loading branch information
sodatea committed Sep 7, 2019
1 parent 74fae44 commit 72ba750
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/@vue/cli-service/lib/util/prepareProxy.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 72ba750

Please sign in to comment.