question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxy issue between two vue apps when created with vue-cli3

See original GitHub issue

Version

3.5.3

Reproduction link

https://github.com/srchulo/vue-cli3-proxy-error

Environment info

  System:
    OS: Linux 3.10 CentOS Linux 7 (Core)
    CPU: (1) x64 Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz
  Binaries:
    Node: 11.13.0 - /usr/bin/node
    Yarn: 1.9.4 - /usr/bin/yarn
    npm: 6.9.0 - /usr/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmGlobalPackages:
    @vue/cli: 3.0.1

Steps to reproduce

  1. Go into public app and type “yarn serve”.

  2. Go into app/ and type “yarn serve”

  3. Go to http://localhost:8080

  4. Open the developer console.

  5. Click “Go to App” link in the top right.

  6. Observe the console (web socket connection closes before it is established, and failed requests show).

  7. Make a change to app/, observe that hot reload will not occur.

What is expected?

Websockets should successfully be proxied to the Vue app on port 8081 and hot reload for the app on 8081 should work.

What is actually happening?

The websockets never connect, there are many failed requests, and hot reload does not work.


I did not have this issue when my project was on vue-cli2-- it was once I upgraded to vue-cli3 that I saw this issue.

These are some of the errors that I observe:

WebSocket connection to 'ws://localhost:8080/app/sockjs-node/946/btaua0jf/websocket' failed: WebSocket is closed before the connection is established.

POST http://localhost:8080/app/sockjs-node/946/2f03xsro/xhr_streaming?t=1554071918837 404 (Not Found)

GET http://localhost:8080/app/sockjs-node/946/a5xm1iat/eventsource 404 (Not Found)

GET http://localhost:8080/app/sockjs-node/139/crmbubvo/eventsource 404 (Not Found)

Additional error that shows from jsonp?c=_jp.aemoxtb:1:

Uncaught SyntaxError: Unexpected token <

After leaving both servers open long enough and having the page opened to /app, then this error will show in the terminal for the public app:

Proxy error: Could not proxy request /app/sockjs-node/266/vz0ie5cy/websocket from localhost:8080 to http://localhost:8081. See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNRESET).

And it will continue to give that error with slightly different arguments after sockjs-node/.

refiling from https://github.com/vuejs/vue/issues/9797 where I misfiled it.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, Apr 1, 2019

Haven’t run the reproduction yet, so this is just from looking at the config:

You haven’t told the proxy to handle websocket connections as well:

module.exports = {
  devServer: {
    host: '0.0.0.0',
    public: '0.0.0.0:8080',
    disableHostCheck: true,
    proxy: {
      '/app': {
        target: 'http://localhost:8081',
        changeOrigin: true,
+        ws: true,
      }
    }
  }
}
0reactions
silhcommented, Feb 20, 2020

Can it be related to this - https://github.com/nodejs/node/issues/23169 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue proxy setting does not work
For an equivalent setup of that proxy, create vue.config.js (if it doesn't exist already) with the following contents:
Read more >
Using the New vue-cli 3 to Scaffold Vue.js Apps
A quick overview of some of the new features with vue-cli version 3 to help you setup zero configuration Vue.js apps.
Read more >
Cli 3.0 connect to node server without causing CORS issue ...
I am in development mode and have a server set up in Node.js that is working fine (tested via postman). I am using...
Read more >
How to deal with CORS error on Vue CLI 3?
In my case, I was serving my Vue application using Vue CLI serve command on localhost:8080 and my backend project was running by...
Read more >
Environment variables
And well add these two variables: .env. PORT=8080 SERVER_PORT=8070. Another idiosynracy of Vue CLI 3 is that the app must use the variable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found