0

I have iis site on my local machine for rest api C#, the site has a host name my-api.my.domain.cld. In hosts file I added 127.0.0.1 my-api.my.domain.cld.

while logging the server adds cookie and from this point entire calls are with credentials true, but cookie is not being sent as part of the requests.

the site is angular http://localhost:4200 server url is http://my-api.my.domain.cld

Any idea how to make cookies work on local site with host name?

Thanks

user3132295
  • 288
  • 4
  • 23
  • There are far too many factors like [these](https://medium.com/swlh/7-keys-to-the-mystery-of-a-missing-cookie-fdf22b012f09) so you have to edit the question to show clearly what cookies you want to send and fail. – Lex Li Aug 30 '21 at 21:30
  • What circumstances will the cookie not be displayed? Is it to call http://my-api.my.domain.cld through an application or to enter the url directly in the browser and it will not be displayed? Please show the code about setting cookie of the site and the code of calling url. – Bruce Zhang Aug 31 '21 at 02:34
  • Thank you for the response, I have an angular site that calls to my-api.my.domain.cld, one call is for login that adds the cookie I can see it in the response, then the site sends another request with credetials true but cookie is not sent as part of the request – user3132295 Aug 31 '21 at 06:13
  • It seems that the CORS affect the authentication. Refer to this [article](https://learn.microsoft.com/en-us/iis/extensions/cors-module/cors-module-configuration-reference) to install CORS on IIS . Then you need set with credetail on each requests. This [thread](https://stackoverflow.com/questions/47304912/angular-4-setting-withcredentials-on-every-request-cors-cookie) will show you how to configure each requests. – Bruce Zhang Sep 01 '21 at 07:15

0 Answers0