我已使用form
submit
创建了html页面。在提交时,我正在调用ajax post
请求。
但抛出错误
无法加载http://radius.a3techlabs.com/app/custom/verifyAccessOTP:对预检请求的响应未通过访问控制检查:“访问控制 - 允许 - 来源”'标头包含无效值''。起源' null'因此不允许访问。
$.ajax({
url: 'http://radius.a3techlabs.com/app/custom/verifyAccessOTP',
dataType: 'json',
type:'post',
headers: {
"charset":"UTF-8",
"accept": "application/json",
"Access-Control-Allow-Origin":"*",
"Access-Control-Allow-Credentials":"true",
},
data:value,
success: function(data) {
console.log(data);
alert(data.message);
}.bind(this),
error: function(xhr, status, err) {}.bind(this)
});
答案 0 :(得分:2)
module.exports.cors = {
allRoutes: false,
origin: '*',
credentials: true,
methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
headers: 'content-type'
};
改变
allRoutes:真
module.exports.cors = {
allRoutes: true,
origin: '*',
credentials: true,
methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
headers: 'content-type'
};
它有效,