错误在Chrome网络访问本地主机API :: ERR_INSECURE_RESPONSE时 [英] Error when accessing localhost api in chrome net::ERR_INSECURE_RESPONSE
问题描述
我试图访问API采用了棱角分明$资源的开发在本地主机上运行,铬控制台给了我错误说ERR_INSECURE_RESPONSE。
我试着在铬禁用网络安全。还是同样的错误。这里是工厂的角度,我用。我怎样才能绕过这个错误,并测试我的应用程序。
ImpactPortal.factory('apiFactory',函数($资源){
返回$资源(https://开头本地主机:8443 / mifosng提供商/ API / V1 / client_impact_portal',{},{
查询:{
方法:GET,
PARAMS:{},
IsArray的:真
}
})
});
您必须先进行身份验证,然后与身份验证令牌一起发送每个请求。
我使用RestAngular所以我的设置可能与你所工作的有一点不同。
这会在你的应用程序配置: -
RestangularProvider.setDefaultHeaders({'X-Mifos平台-TenantId':'默认'});
和这样的事情会在你的控制器/服务
VAR登录= Restangular.all('验证用户名= mifos&放大器;密码=密码')后(),然后(功能(用户){。
的console.log(用户);
},函数(){
的console.log(有挽救的错误);
});
I was trying to access api running in localhost using angular $resourses, chrome console gives me error saying ERR_INSECURE_RESPONSE.
I tried disabling web security in chrome. still same error. here is the angular factory that i used. How can I bypass this error and test my app.
ImpactPortal.factory('apiFactory', function ($resource) {
return $resource('https://localhost:8443/mifosng-provider/api/v1/client_impact_portal', {}, {
query: {
method: 'GET',
params: {},
isArray: true
}
})
});
You must authenticate first and then send each request along with the auth token.
I am using RestAngular so my settings might look a little different from what you are working on.
This will go in your application config :-
RestangularProvider.setDefaultHeaders({ 'X-Mifos-Platform-TenantId': 'default' });
and something like this will go in your controller/service
var login = Restangular.all('authentication?username=mifos&password=password').post().then(function(user) {
console.log(user);
}, function() {
console.log("There was an error saving");
});
这篇关于错误在Chrome网络访问本地主机API :: ERR_INSECURE_RESPONSE时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!