我有一个旧的android
应用程序,我正在寻找重构到ìonic2
来创建一个跨平台的应用程序。角创建交叉起源http请求
,我使用Jsoup
通过以下调用Jsoup.connect(url).get();
这工作没有问题,我返回的HTML页面,我可以解析。 不过,如果我尝试这与ionic2(angular2)使用以下
loadTimetableData(url) {
let headers = new Headers({
'Content-Type': 'application/form-url-encoded;',
'Access-Control-Allow-Origin': '*'
});
return this._http.get(url, { headers: headers }).map((res) => res).catch(this._errorHandler);
}
我得到的标准CORS错误(index):1 XMLHttpRequest cannot load ${URL}. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. The response had HTTP status code 400.
这不是我的服务器,所以我不能添加页眉服务器端。有没有我可以使用其他的图书馆,或者我怎么能解决这个问题,如果在所有
这是不幸的是服务器端的问题,你可以从浏览器修复它绝对没有。我能想到的唯一方法就是使用代理来注入缺少的头文件。 – cgTag