gpt4 book ai didi

jquery - Access-Control-Allow-Origin header 包含无效值

转载 作者:行者123 更新时间:2023-12-04 14:24:38 25 4
gpt4 key购买 nike

我用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com