vue3.0 配置公共请求地址

正常请求接口:  

  return request({
    url: 'http://192.168.1.0/User/cancelUpgrade',
    method: 'get',
    params: data
  })
 
vue.config.js里配置    记住重启
 
  devServer: {
    host: '0.0.0.0',
    port: 8080,
    proxy: {
      '/api': {
        target: 'http://192.168.1.0/',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }
  }
 
axios封装里:
  
  const service = axios.create({
    baseURL: '/api' ,
  })
 
原文地址:https://www.cnblogs.com/Mr-Rshare/p/10063645.html