0

I am sending a post auth request from my localhost to a remote server to get response cookies returned by server(using ionic proxy to solve CORS). From chrome network inspector, I can see the response cookie has been returned from server. However, I am not able to access it from $http post response. I try almost everything from other posts and I still can not get the cookie. What I have tried

  • I use ngCookie and $timeout combination. Basically I get an empty object when I use $cookie.getAll() which I assume the cookie is not there
  • I also set withCredentials to true
  • I also tried headers.get('set-cookie')

My angular version is 1.5.3. Please help

Below is my code

angular.module('starter.controllers', ['ngCookies'])

.controller('DashCtrl', function($scope, $http, $cookies, $timeout) {
$http({
    method: 'POST',
    url: '/api/User/Authenticate',
    data: {
      Username: 'xxx',
      Password: 'xxx'
    },
    withCredentials: true
  }).then(function(response) {
    $timeout(function() {
      console.log($cookies); // return {}
      console.log($cookies.getAll()); // return {}
    });
  }, function(response) {

  });
})

Here is the server response enter image description here

eded
  • 3,778
  • 8
  • 28
  • 42

0 Answers0