Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.9k views
in Technique[技术] by (71.8m points)

vue-cli3 api代理问题

image
image
本机:192.168.0.245;
目标的地址:192.168.0.222;
接口封装后,方法是:
function getList(params){

const url = '/url';
return $axios.get(url,params)

}
代理结果是:http://192.168.0.245/'192.168.0.222'/url
这是什么原因。

vue.config.js内proxy:
`proxy: {

        [process.env.VUE_APP_BASE_API]: {
            target: process.env.VUE_APP_BASE_API,
            changeOrigin: true,
            secure: false,
            pathRewrite: {
                ['^' + process.env.VUE_APP_BASE_API]: ''
            }
        }
    }`
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

devSever的proxy原理是作为中转站代理转发,所以浏览器看到的还是原来的地址


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...