天天看点

axios get怎么还会显示跨域_【解惑】axios请求同一接口,post请求没问题,get请求跨域...

前提条件:

1.正式服务器IIs部署 前后端部署在同一容器下

2.系统中其他所有的get请求都不跨域,只有这一个功能接口,get请求都跨域 post没问题

3.后台配置了 允许跨域的配置

4.axios没有修改过别的,只配置了拦截器

5.本地联调等等情况下都没问题,只有正式环境出问题 IIS也配置过了跨域

`

download() {

this.$axios

.post(`/a/taskStation/exportExcelDataList?taskId=${this.taskId}`, {

responseType: "blob"

})

.then(res => {

const blob = new Blob([res]); //new Blob([res])中不加data就会返回下图中[objece objece]内容(少取一层)

const fileName = "xxxx.xls"; //下载文件名称

const elink = document.createElement("a");

elink.download = fileName;

elink.style.display = "none";

elink.href = URL.createObjectURL(blob);

document.body.appendChild(elink);

elink.click();

URL.revokeObjectURL(elink.href); // 释放URL 对象

document.body.removeChild(elink);

});

},

`

axios get怎么还会显示跨域_【解惑】axios请求同一接口,post请求没问题,get请求跨域...
axios get怎么还会显示跨域_【解惑】axios请求同一接口,post请求没问题,get请求跨域...
axios get怎么还会显示跨域_【解惑】axios请求同一接口,post请求没问题,get请求跨域...
axios get怎么还会显示跨域_【解惑】axios请求同一接口,post请求没问题,get请求跨域...

postman 返回响应头

axios get怎么还会显示跨域_【解惑】axios请求同一接口,post请求没问题,get请求跨域...