Skip to content
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

proxy error using vue-cli-service serve #171

Open
spencerflagg opened this issue Jun 17, 2020 · 1 comment
Open

proxy error using vue-cli-service serve #171

spencerflagg opened this issue Jun 17, 2020 · 1 comment

Comments

@spencerflagg
Copy link

I've started a project based on this template, and I'm struggling with the devServer proxy. Here's the relevant config:

package.json

"scripts": {
    "start": "run-s build api",
    "api": "cross-env NODE_ENV=testing ARC_LOCAL=1 npx sandbox",
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "eslint src --ignore-pattern node_modules --fix"
  }

vue.config.js

devServer: {
    proxy: {
      '^/api': {
        target: 'http://localhost:3333'
      }
    }
  },

my issue

  • If I run run-s build api, Vue is built for production, served up on localhost:3333, and the connection to the api works flawlessly.
  • But if I run run-s serve api, Vue is served up for dev on localhost:8080, and I get this error when trying to hit the api via the devServer proxy:
Proxy error: Could not proxy request /api/ from localhost:8080 to http://localhost:3333 (ECONNREFUSED).

I've searched around for answers, and I've found a handful, but they've all been suggested by people with the caveat "it works, but I'm not sure why", and none of them work for me.
Here are the changes I've tried already:

devServer: {
    proxy: {
      '^/api': {
        target: 'http://127.0.0.1:3333', /* tried changing localhost to 127.0.0.1 */
        target: 'http://[::1]:3333', /* tried changing localhost to [::1] */
        secure: false, /* tried adding this */
        changeOrigin: true /* tried adding this */
      }
    }
  },

Any help would be greatly appreciated, thanks!
(Originally posted on Spectrum.)

@kristoferjoseph
Copy link
Member

Not sure where to file this issue because it relates to Vue cli documentation
https://new-issue.vuejs.org/?repo=vuejs/vue-cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants