0

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

Johan
  • 3,577
  • 1
  • 14
  • 28
AnaCS
  • 976
  • 4
  • 15
  • 32
  • 1
    Can you please add the desired behaviour? Right now it's a bit unclear what your question is. – Johan Sep 27 '18 at 17:33
  • Inside the cookie, where it says language = us-US , I want it to say pt-PT since that is what I have on my code – AnaCS Sep 27 '18 at 17:36
  • 1
    Great :) Edit your question and add that that's the result you're looking for. Not everyone looks through the comments. – Johan Sep 27 '18 at 17:37
  • 1
    https://stackoverflow.com/questions/30216155/can-i-change-accept-language-request-header-with-angularjs/37439756 – Jameel Moideen Sep 27 '18 at 17:51
  • @JameeIM thanks but I am not asking about the accept language , but the cookie itself carrying a variable called language and then it's value – AnaCS Sep 28 '18 at 10:31

1 Answers1

1

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'}).

LM555
  • 26
  • 1
  • 3
  • This helped the cookie to disappear from outside the cookie field, it no longer appears as a header tho this doesn't seem to change the language for me and I don't think the domain is wrong, thanks , I will keep looking – AnaCS Sep 28 '18 at 10:32