title: Using Proxy , Cookies not sent in angular 4 app using withCredentials set to true
body: <p>I am host angular 4 app on my localhost , Since I need to make api request to my backend which is hosted on web (say  <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a> ) I am using proxy . Here is my proxy config file. </p>
  
  <pre><code>  "*": {"target":"https://example.com",
  "secure": false,
  "logLevel": "debug",
  "changeOrigin": true }
  </code></pre>
  
  <p>So that every request I make goes through the target url . When I make my first request to login page with credentials included I receive cookies in response.But then when I make another request ( POST ) to  <a href="https://example.com/images" rel="nofollow noreferrer">https://example.com/images</a> I am redirected to the login page . I can see in my network that there are no cookies being sent with the Request headers, however I did receive them from my first login request . I checked out many solutions to this problem. Many of them asked to include {withCredentials=true} in my ajax request which I did in every request.Here is my request </p>
  
  <pre><code> $.ajax({
              url: "https://example.com/images",
              type: "POST",
              crossDomain:true,
              headers: {
                 // includes necessary headers .
                },
              xhrFields: {
                  withCredentials: true
              },
  
              data:data1 ,
              //data1 is json formatted
  
  
              success: function (res) {
                  console.log(res)
              },
              error: function (xhr, status) {
                  console.log(status);
              }
          });
  </code></pre>
  
  <p>But this did not solve the problem. I suspect the cookies are getting lost due to proxy , or the browser is not handling them correctly. I checked I have allowed third party cookies . I need to send those session cookies with this second request . I tried to manually add them but I did not find a way to get and send them along with this request. how can I tackle this issue ? If I remove proxy then I will get the CORS issue . I do not have access to the backend server. hence I tried handling CORS using proxy which works correctly for login request. But this second request is not being sent with cookies. Anyone who can  help with this ?  </p>