问题描述
// 直接使用访问可以拿到数据
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
target: 'https://XXXXXXX.com/company',