使用vs2017打开一个网站项目并在本地运行,然后引用本地iServer11.0.1上的data服务,但会报跨域,iServer11.0.1里面只加了一个data服务,请问这是什么原因?
引用代码如下:
function getAnalyzedData() {
new ol.supermap.DatasetService(dataUrl).getDatasets("KenkeiResultDemo", function (serviceResult) {
try {
var datasetNames = serviceResult.result.datasetNames;
datasetsSelect = document.getElementById("analyzedDataSel");
for (let i = 0, len = datasetNames.length; i < len; i++) {
datasetsSelect.options[i + 1] = new Option(datasetNames[i], datasetNames[i]);
}
}
catch (e) { console.log("getDatasets error."); }
});
}
跨域报错如下:
Access to fetch at 'http://localhost:8090/iserver/services/data-KenkeiDemo/rest/data/datasources/name/KenkeiResultDemo/datasets.json' from origin 'http://localhost:61974' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
之前iServer10.1.2请求是正常的,换成11.0.1就这样了,请问是iServer设置有什么问题吗