Vue 实现请求转发【Vue小技巧】

其生

关注

阅读 43

2022-05-26

通过nodejs的请求转发到后台,

前端地址:http://localhost:8080   后端地址:http://localhost:8081

 

在vue.config.js里面配置这个代理(找到config/index.js 配置文件 )

module.exports = {
derServer:{
proxy:{
'/api':{
target:'http://localhost:3000'
}
}
}

}

 然后就可以axios.get('/api').then(res=> {})


精彩评论(0)

0 0 举报