I have check all the post about setting the cookie via Header, and I always see that the people recommend put this:
withCredentials: true
I'm trying to do it and got the same error.
$scope.myAppsLoginResponse = JSON.stringify(response.data, null, 3);
var dataC = JSON.parse($scope.myAppsLoginResponse);
$cookies.cookie = 'Somethin here as cookie';
var userId = dataC.user_id;
var thePath = '/thePath';
var theURL = 'https://theUrl';
var cookieRes = $cookies.cookie;
document.cookieMyApp = cookieRes;
var headers2 = {};
headers2 ['Accept-Language'] = 'es-ES';
headers2 ['Cookie'] = document.cookieMyApp;
headers2 ['Authorization'] = 'Basic Z2743ASasdh23Q=';
var param = {}
param ['userId'] = userId;
var req2 = {
method: 'GET',
url: theURL + thePath ,
headers: headers2,
params: param,
xhrFields: {
withCredentials: true
}
}
Response:
Refused to set unsafe header Cookie