vue cli 3 配置代理,报错404

新手上路,请多包涵

问题描述

// 直接使用访问可以拿到数据
https://.com/company/info

使用 vue cli 3 配置后,
module.exports = {
devServer: {

proxy: {
  '/company': {
    target: 'https://XXXXXXX.com/',
    // websocket
    // wx: true,
    changeOrigin: true,
    pathRewrite: {
      '^/company': ''
    }
  }
}

}
}

// 使用接口后 '/company/info' 接口报错404
axios({

method: 'POST',
url: '/company/info',
data

})

报错信息:
Request URL: http://localhost:8080/company/info
Request Method: POST
Status Code: 404 Not Found
Remote Address: 127.0.0.1:8080
Referrer Policy: no-referrer-when-downgrade

阅读 5.5k
2 个回答
新手上路,请多包涵

应该去掉pathRewrite吧

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题