我用 form
创建了 html 页面submit
.提交时,我正在调用 ajax post
要求。
但抛出错误
Failed to load http://radius.a3techlabs.com/app/custom/verifyAccessOTP: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains the invalid value ''. Origin 'null' is therefore not allowed access.
$.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)
});
最佳答案
module.exports.cors = {
allRoutes: false,
origin: '*',
credentials: true,
methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
headers: 'content-type'
};
改变了
allRoutes:true
module.exports.cors = {
allRoutes: true,
origin: '*',
credentials: true,
methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
headers: 'content-type'
};
有用,
关于jquery - Access-Control-Allow-Origin header 包含无效值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48415706/