Taro.uploadFile 跨域请求 include
-
Access to XMLHttpRequest at 'http://118.114.239.144:8181/jobs/uploadPic' from origin 'http://192.168.0.50:10086' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
通过uploadFile上传图片,出现上面报错问题,请问下该怎么解决
-
@wangbangtao 设置一下 'Access-Control-Allow-Origin' ?
-
在服务端设置了。解决了
-
Taro.uploadFile({ url: url filePath: tempFilePaths[0], withCredentials: false, name: 'file', })
增加withCredentials参数即可,因为默认接口参数为 withCredentials: true,但文档并没有指出