通过配置peoxyTable实现跨域,但是浏览器报了404的错误
proxyTable的配置
dev: {
env: require('./dev.env'),
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
target: 'http://172.16.2.207:8765',
changeOrigin: true,
pathRewrite: {
'^/api': '/'
}
}
},
请求
this.$axios({
method: "post",
baseURL: "/api",
url: "/uaa/oauth/token",
data: {
"scope": 'openid',
"grant_type": 'password',
"username": this.loginForm.user_name,
"password": this.loginForm.pass
},
params: param,
headers: {
'Authorization': 'Basic ' + btoa(username+':'+password),
'Content-Type':'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
},
withCredentials:true,
transformRequest: [data => {
return qs.stringify(data);
}],
paramsSerializer: function(params) {
return qs.stringify(params, {arrayFormat: 'brackets'})
},
auth: {
username: username,
password: password
},
})
.then(request => {
console.log(1);
})
.then(response => {
console.log(2)
})
浏览器报错
请问这是什么原因?