Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vod_reporter.js引起的跨域问题 #10

Open
anitakym opened this issue Dec 9, 2019 · 0 comments
Open

vod_reporter.js引起的跨域问题 #10

anitakym opened this issue Dec 9, 2019 · 0 comments

Comments

@anitakym
Copy link

anitakym commented Dec 9, 2019

1.在项目中引用SDK,报Access to XMLHttpRequest at 'https://vodreport.qcloud.com/ugcupload_new' from origin 'http://xxx.xxx.cn' 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
的跨域问题;

2.项目本身设置了axios.defaults.withCredentials = true

3.在vod_reporter.js的172增加axios_1.defaults.withCredentials = false,之后再进行打包,不再报跨域问题
VodReporter.prototype.send = function (reportData) {
if (util_1.default.isDev || util_1.default.isTest) {
console.log("send reportData", reportData);
return;
}
axios_1.defaults.withCredentials = false; //172行增加了这个
axios_1.default.post(this.reportUrl, reportData);
};

提问:针对这种情况,怎么处理合适呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant