-
Notifications
You must be signed in to change notification settings - Fork 0
proxy error using vue-cli-service serve #171
Copy link
Copy link
Open
Description
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.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels