问题描述
我需要在VUE调用供应商提供的外部WADL(应该是用的JEREY框架,POST)地址,在本地通过config/index.js下proxyTable配置可以运行并调用接口成功。
现在需要部署到服务器的tomcat上,但一直报 XMLHttpRequest cannot load http://:7001/getuser. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://:8009' is therefore not allowed access. 在网上的帖子都通不过(web.xml过滤器配置、JSONP、QS)。
现在我只能修改tomcat的配置已经http header,接口与后端不做修改,请问能怎么做的到。请大家指教一下
问题出现的环境背景及自己尝试过哪些方法
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
axios.post(process.env.API_HOST + '/*ser', {//
TYPE: 'V',
USER_NAME: this.username
}).then(function (response, headers) {
if (response.status === 200) {
if (response.data.l_RET_STATUS == 'Y') {
window.sessionStorage.userName = self.username;
this.showupError = false;
this.$router.push('/home');
} else {
this.showupError = true;
}
} else {
alert('网络错误,请稍后再试!')
}
}
).catch(function (error) {
alert('请求错误')
});