Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs – 访问chrome net :: ERR_INSECURE_RESPONSE中的localhost api时出错大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图使用angular $resourses访问在localhost中运行的api,chrome console给出了错误说ERR_INSECURE_RESPONSE.

我尝试在Chrome中禁用网络安全性.还是一样的错误.这是我使用的角度工厂.如何绕过此错误并测试我的应用.

ImpactPortal.factory('apiFactory',function ($resourcE) {
    return $resource('https://localhost:8443/mifosng-provider/api/v1/client_impact_portal',{},{
        query: {
            method: 'GET',params: {},isArray: true
        }
    })
});

解决方法

您必须先进行身份验证,然后将每个请求与身份验证令牌一起发送.

我正在使用RestAngular,因此我的设置可能与您正在处理内容略有不同.

这将在您的应用程序配置中进行: –

RestangularProvider.setDefaultHeaders({ 'X-Mifos-Platform-TenantId': 'default' });

这样的东西会进入你的控制器/服务

var login = Restangular.all('authentication?username=mifos&password=password').post().then(function(user) {
   console.log(user);
 },function() {
  console.log("There was an error saving");
 });

大佬总结

以上是大佬教程为你收集整理的angularjs – 访问chrome net :: ERR_INSECURE_RESPONSE中的localhost api时出错全部内容,希望文章能够帮你解决angularjs – 访问chrome net :: ERR_INSECURE_RESPONSE中的localhost api时出错所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。