-
-
Couldn't load subscription status.
- Fork 6.3k
Closed
Description
Version
3.0.0-rc.3
Reproduction link
https://jsfiddle.net/tecoholic/y76qcsha/
Steps to reproduce
Set the proxy in vue.config.js as
module.exports = {
devServer: {
port: 4000,
proxy: {
"/api": {
target: "http://localhost:5000/"
},
"/users": {
target: "http://localhost:5000/"
}
}
}
}Now all the requests to localhost:4000/user and /api should be proxied to the localhost:5000
What is expected?
By default http-proxy-middleware configures the proxy with changeOrigin: false, so a request should be proxied without changing the origin. The response should be:
curl -I http://localhost:4000/users/login
HTTP/1.1 301 MOVED PERMANENTLY
X-Powered-By: Express
server: gunicorn/19.8.1
date: Sun, 15 Jul 2018 05:11:22 GMT
connection: close
content-type: text/html; charset=utf-8
content-length: 275
location: http://localhost:4000/users/login/
What is actually happening?
curl -I http://localhost:4000/users/login
HTTP/1.1 301 MOVED PERMANENTLY
X-Powered-By: Express
server: gunicorn/19.8.1
date: Sun, 15 Jul 2018 05:09:52 GMT
connection: close
content-type: text/html; charset=utf-8
content-length: 275
location: http://localhost:5000/users/login/
Notice the port 5000 in the response.
When I update the config to read
module.exports = {
devServer: {
port: 4000,
proxy: {
"/api": {
target: "http://localhost:5000/"
},
"/users": {
target: "http://localhost:5000/",
changeOrigin: false
}
}
}
}I get the expected response without change of the Origin. By default the changeOrigin flag is supposed to be off, but I have to set it off explicitly when using vue-cli-service serve.