在config  index.js文件中

vue前后端端口不一致解决方案

引入如下代码即可

vue前后端端口不一致解决方案

proxyTable: {

'/api': {

target: 'http://localhost:3000',//要访问的后端接口

changeOrigin: true,

pathRewrite: {

'^/api': '/'

//这里的配置是正则表达式,以/api开头的将会被用用‘/api'替换掉,假如后台文档的接口是 /api/list/xxx

//前端api接口写:axios.get('/api/list/xxx') , 被处理之后实际访问的是:http://news.baidu.com/api/list/xxx

}

}},

 

 

 

相关文章:

  • 2022-12-23
  • 2021-05-20
  • 2021-12-22
  • 2021-08-10
  • 2021-05-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2022-01-03
  • 2021-11-05
  • 2021-07-22
  • 2021-06-16
相关资源
相似解决方案