Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

vue的proxy配置

本地调试的时候后端域名是domain.com
希望配置个proxy让请求/xyz的时候转发到/zbc

我在vue.config.js里配置

devServer: {
    proxy: {
      '/xyz': {
        target: 'http://domain.com/',
        changeOrigin: true,
        pathRewrite: {
          '^/xyz': '/abc',
        },
      },
    },
  },

但是没有效果,有点懵。
用的axios发送的请求
domain是用.env.beta文件配置的process.env
api封装格式大概是

// 获取公司信息
export function getCompanyInfo(params) {
  return request({
    url: '/xyz/api/companyInfo/basicInfo',
    method: 'GET',
    params,
  });
}

请问是哪里有问题吗?


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

1 Answer

0 votes
by (71.8m points)
  1. 请求的是domain.comtarget上加上了xyz干啥
  2. .env.beta这是个什么配置文件,疑惑
  3. axios请求没有配置baseURL/xyz吗?,如果配置了,你请求前面不需要再加上/xyz

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...