CORS过滤器启用码这是我的js文件,下面的代码里面.controller我应该在哪里写angularjs
xhr.onreadystatechange = function() {
if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200){
$http.post(smsHorizon,'Access-Control-Allow-Origin', '*').then(function(res){
res.addheader('Access-Control-Allow-Origin', '*');
res.addheader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.addheader('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
if(res){
alert("OTP has been Send");
}
})
}
else{
}
}
这是编写CORS的方式吗?请帮忙!!!
你应该添加标题在服务器端 –
这是它使用另一个API –
的指南,以使服务器端CORS码 - https://开头enable-cors.org/ –