-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Custom sockPath for sockjs-node (HMR) partially fails #4400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
🤔 Please ? Anybody ? |
+1 on this and also doesn't use the sockHost available on dev-server |
+1 - only first query go to devServer.sockPath (/admin/sockjs-node/info in my case). others go to /sockjs-node/info |
Workaround:
|
Thanks @kakenbok - I have confirmed that the following workaround inspired by you resolves the issue for me. // vue.config.js
const publicHost = 'foo.localhost';
const publicPath = '/subdir/';
const sockPath = `${publicPath}sockjs-node`;
module.exports = {
devServer: {
// ...
public: publicHost,
sockPath // broken in vue-cli - see workaround below
},
publicPath,
// ...
configureWebpack: (cfg) => {
// TEMPORARY workaround for https://github.com/vuejs/vue-cli/issues/4400 and https://github.com/vuejs/vue-cli/issues/5372
cfg.plugins.push({
apply: (compiler) => {
compiler.hooks.entryOption.tap('entry', () => {
const clients = compiler.options.entry.app;
for (const index in clients) {
if (clients[index].endsWith(`${publicHost}/sockjs-node`)) {
clients[index] = clients[index].replace(`${publicHost}/sockjs-node`, `${publicHost}&sockPath=${sockPath}`);
}
}
});
}
});
}
}; |
With those workarounds I get the web socket to connect, but hot reloading isn't working anyways. Has anyone else had similar issues? |
Note: I was using kakenbok's fix for a while, but my reverse proxies were misconfigured. Once I was able to have the websocket connections go through, my webpack chunk If you get strange behaviour where your webpack chunks aren't being delivered properly, best to try blocking the websockets and refreshing to see if it's related. |
Interestingly, my hot-reload was working when the sockjs websockets failed to upgrade (normal http was still passing through), but now that the sockets connect, my site breaks due to the webpack issues mentioned in my last comment |
vue.config.js module.exports = {
publicPath: "/testapp/",
devServer: {
// historyApiFallback: false,
disableHostCheck: true,
public: "0.0.0.0",
sockPath: "/testapp/sockjs-node/",
port: 80,
},
configureWebpack: {
plugins: [
{
apply: compiler => {
compiler.hooks.entryOption.tap("entry", () => {
const clients = compiler.options.entry.app;
for (const index in clients) {
if (clients[index].match(/sockjs-node/)) {
clients[index] = clients[index].replace(
"0.0.0.0/sockjs-node",
"0.0.0.0&sockPath=/testapp/sockjs-node/",
);
}
}
});
},
},
],
},
} apache (my toplevel proxy) conf ProxyPass /testapp/sockjs-node/ ws://myNGINX/sockjs-node/
ProxyPassReverse /testapp/sockjs-node/ ws://myNGINX/sockjs-node/
ProxyPass /testapp/ http://myNGINX/
ProxyPassReverse /testapp/ http://myNGINX/ nginx/conf.d/default.conf (myNGINX host) location ^~ / {
proxy_pass http://myVueApp:80/testapp/; # publicPath
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
# add_header X-Content-Type-Options nosniff; # When .js files redirect to .html, we want to know.
} Normal page load, when trying to get webpack chunk
Note that the Manual request, serves proper
Presumably this means that somewhere along the line, the chunk is being requested at So I'll have to either add more exceptions to my dev nginx conf or find out why it's doubling up my path EDIT: |
DANKE (thanks) very much!!! @AlbertBrand + @sodatea |
Version
3.10.0
Reproduction link
https://github.com/fleebzz/vue-cli-sockjs-path-issue
Environment info
Steps to reproduce
yarn serve
http://localhost:9090/sub-folder
GET http://localhost:9090/sub-folder/sockjs-node/info
which succeedsGET http://localhost:9090/sockjs-node/info
wich failsWhat is expected?
Only one
/info
requestWhat is actually happening?
Two requests to
sockjs-node/info
with one ignoring the custom socket pathSecond request should not happen and throws a lot of 404 errors in console.
The error seems to come from
vue-cli
and not fromwebpack-dev-server
. See following repository with same behavior but withoutvue-cli
and onlywebpack-dev-server
, it works : https://github.com/fleebzz/webpack-sockjs-path-issue.The text was updated successfully, but these errors were encountered: