项目 proxy.json文件里
{"/heatinggo": {"target": "http://10.133.251.101:9527","secure": false,"pathRewrite": {"^/heatinggo": ""}},"/qhj/heatinggo": {"target": "http://10.133.251.101:8080","secure": false,"pathRewrite": {"^/qhj/heatinggo":""}}}
我的 api=’/heatinggo’
我的请求地址 ${api}/xxxx/xxx ,请求地址就为 ‘/heatinggo/xxxx/xxx’
当node服务器 遇到 以 ‘/heatinggo‘ 开头的请求,就会把 target 字段加上,那么我的请求地址就为 http://10.133.251.101:9527/heatinggo/xxxx/xxx
下面的 pathRewrite 表示的意思是 把/heatinggo 替换为 空,那么我的请求地址就为 http://10.133.251.101:9527/xxxx/xxx(用在如果你的实际请求地址没有 heatinggo 的情况)
changeOrigin默认是false:请求头中host仍然是浏览器发送过来的host。
如果设置成true:发送请求头中host会设置成target。
