CORS 配置不起作用
CORS configuration not working
谁能帮我找到正确的 CORS 方法。我收到错误
XMLHttpRequest 无法加载 https://***********/gateway.com。请求的资源上不存在 'Access-Control-Allow-Origin' header。因此不允许来源'http://localhost:7089'访问
参考之前与 CORS 相关的 post 创建了以下代码。
Java脚本代码如下:
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
function CallWS(){
var request = createCORSRequest("POST","https://**************/gateway.com");
if (request){
request.onload = function(){
var res = request.responseText;
alert(res);
};
request.send();
}
在尝试进行 CORS 调用时,您需要在 HTTP 服务器上启用 CORS。当您请求初始页面时,服务器应以该页面和允许访问源响应 header here 您会找到更详尽的解释
谁能帮我找到正确的 CORS 方法。我收到错误
XMLHttpRequest 无法加载 https://***********/gateway.com。请求的资源上不存在 'Access-Control-Allow-Origin' header。因此不允许来源'http://localhost:7089'访问
参考之前与 CORS 相关的 post 创建了以下代码。 Java脚本代码如下:
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
function CallWS(){
var request = createCORSRequest("POST","https://**************/gateway.com");
if (request){
request.onload = function(){
var res = request.responseText;
alert(res);
};
request.send();
}
在尝试进行 CORS 调用时,您需要在 HTTP 服务器上启用 CORS。当您请求初始页面时,服务器应以该页面和允许访问源响应 header here 您会找到更详尽的解释