el-ui 上传文件 response must not be the wildcard '*' when the request's credentials mode is 'include'.

el-ui上传文件报错:

response must not be the wildcard '*' when the request's credentials mode is 'include'.

Origin 127.0.0.1:9527  is therefore not allowed access.the credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute

原因是设置了 withCredentials为true,

withCredentials设置为true为 支持发送 cookie 凭证信息,如果报错则去除withCredentials改为

<el-upload
		v-model="formFile.file"
		class="upload-demo"
           <!-- 重点-->
		:action="fileUrl"
		:headers="headersParams"
         <!-- 重点-->
		:before-upload="beforeUpload"
		:on-success="handleSuccess"
		:on-error="handleError"
		:limit="1"
		:file-list="fileList">
<script>
import { getToken } from '@/utils/auth'
import { FILE_URL } from '@/utils/request'
//某个方法中设置
// 上传地址 FILE_URL 为 http:127.0.0.1:8080
this.fileUrl = FILE_URL + `/api......'
this.headersParams = {
	Authorization: this.$store.getters.token
}

</script>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值