3

i use HttpClient for a CORS post request from "example.fr" to "api.example.fr".

I receive the correct value from my REST API Server :

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:content-type
Access-Control-Allow-Methods:POST, GET, DELETE, PUT, OPTIONS
Access-Control-Allow-Origin:http://example.fr
Access-Control-Max-Age:3600

But I need to send my Cookies to api.example but that doesn't work.

I am calling post method like:

return this.http.post(Config.ROUTES.auth.register, user, { withCredentials: true, })
      .catch(Utils.handleError);

Can someone help me please ? Thanks a lot.

yurzui
  • 171,085
  • 24
  • 365
  • 354
Spawnrad
  • 326
  • 2
  • 15
  • 1
    make sure your client and server are in the same domain. – Sachila Ranawaka Oct 02 '17 at 16:29
  • Thanks for your answer @SachilaRanawaka. My API is in the same domain. I just use the subdomain api.example.fr. The cookie can't be sent from a parent domain : example.fr to a subdomain api.example.fr ? – Spawnrad Oct 02 '17 at 16:51
  • 2
    It depends on how the cookie was set. See https://stackoverflow.com/questions/18492576/share-cookie-between-subdomain-and-domain – GreyBeardedGeek Oct 02 '17 at 17:09
  • Thanks a lot guys have change my Cookie domain to .example.fr and it works !! Thanks again :) – Spawnrad Oct 02 '17 at 17:17

0 Answers0