AnaCS
AnaCS

Reputation: 1011

send cookie inside request angularjs http get

I have the following http get , that I would like to send a cookie with a language on the request, but turns out with $cookieStore, it sends the cookie outside of the request

$cookieStore.put("language", "pt-PT");

I tried this as well

var myObject = {
    headers: { 'language': 'pt-PT'}
}//ignored

return $http.get(comm.endpoints.getEntityFinancialPosition, myObject );

In my debug I can see that this just created a new header that is not sent inside the cookie enter image description here

Upvotes: 0

Views: 101

Answers (1)

LM555
LM555

Reputation: 26

The scope of the cookie is restricted with the domain option. If page domain is different than API domain cookie will not be sent when making a request. To fix that set the right domain for the cookie $cookieStore.put("language", "pt-PT", {domain: 'requestdomain.com'}).

Upvotes: 1

Related Questions