错误403,对预检请求的响应。在PUT AngularJs之后

时间:2017-10-10 15:08:34

标签: angularjs rest put

我在使用此功能时遇到了麻烦:

$scope.modificaPassword = function () {
    var loginId,token,newPass,oldPass;

    loginId = angular.fromJson(window.localStorage['user']).loginId;
    token = angular.fromJson(window.localStorage['user']).token;
    oldPass = $scope.cambioPasswordData.oldpassword;
    newPass = $scope.cambioPasswordData.newpassword1;

    $http({
       method: "PUT",
       url: "http:// . . . /cqrest/api/webapp/auth/login",
       headers: {
         'loginId': loginId,
         'token': token,
         'oldpassword': oldPass,
         'newpassword': newPass
       },
     }).then(function mySuccess(response) {
       if(response.data){
         alert("Password modificata correttamente");
       }else{
         if($scope.checkToken()){
           alert("La vecchia password non corrisponde");
         }else{
           //disconnesso
         }
       }
     }, function myError(response) {
       alert("Errore " + response.data);

       $scope.error = response.data;

     });
  }

我需要联系休息服务来更改帐户密码,问题是

Failed to load http://. . . /api/webapp/auth/login: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http:// . . . ' is therefore not allowed access. The response had HTTP status code 403.
2angular.min.js:93 
OPTIONS http:// . . . /cqrest/api/webapp/auth/login 403 ()
    (anonymous) @ angular.min.js:93
    q @ angular.min.js:89
    g @ angular.min.js:86
    (anonymous) @ angular.min.js:118
    $eval @ angular.min.js:132
    $digest @ angular.min.js:129
    $apply @ angular.min.js:133
    (anonymous) @ angular.min.js:252
    dispatch @ jqueryb8ff.js?ver=1.12.4:3
    r.handle @ jqueryb8ff.js?ver=1.12.4:3

我已经使用angular来调用rest put回调,但我还没有得到这个错误。我该怎么办 ? 我也尝试使用postman检查服务是否正常工作,它是......并且参数的传递方式正确。

0 个答案:

没有答案