我知道在这个主题上已有很多关于SO的资源和信息,但没有一个帮助我解决我遇到的问题。
当然,我尝试访问其他域中的数据。我试图从NPI注册管理机构https://npiregistry.cms.hhs.gov获取提供商的数据。我暂时使用https://crossorigin.me,但它非常不可靠。我曾经在URL中使用此数据获取数据:https://crossorigin.me/https://npiregistry.cms.hhs.gov/api/?number=1245563469
此外,我的公司或crossorigin阻止了我们的IP范围。所以,现在我需要能够创建自己的。
我使用的是AngularJS 1.5.8。
this.getPrescriber = function (npi) {
var request = $http({
method: 'GET',
url: 'https://npiregistry.cms.hhs.gov/api/?number=' + npi,
headers: { 'Content-Type': 'application/json;charset=utf-8' }
});
return (request.then(handleSuccess, handleError));
};
然后设置配置
app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);
它仍然没有奏效。我一直得到同样的#34; NO Access-Control-Allow-Origin"错误。那么,如果没有为GET请求设置NPI注册服务器,那么crossorigin.me是如何做到的呢?我怎样才能在我的应用程序中复制它?