出现此错误:
GET https://url 503 (Service Unavailable)
employee_cost_new#:1 Access to XMLHttpRequest at 'https://url' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
我正在使用此设置进行ajax调用,它在localhost上运行正常,但在https url上出现错误:
NodeJs_API_Helper.prototype.getAjaxCommonSettings = function(url){
console.log('Auth', this.getCookie());
var settings = {
"async": true,
"crossDomain": true,
"headers": { 'Auth': this.getCookie() },
"method": "GET",
"url": url
};
return settings;
};
在服务器中已完成此操作:
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Auth");