title: Losing session at every REST call
body: <p>I have an Angular app on <code>http://localhost:4200/myfrontend</code> that gets data from a Java REST api on <code>http://localhost:8080/mybackend</code>. Within the Angular app though, every time I reach out to the REST api a new session is created.</p>
  
  <p>I created a test where I put both frontend and backend on <code>http://localhost:8080</code> and the session was not lost.</p>
  
  <p>The settings I set for the Java REST backend are:</p>
  
  <pre><code>response.getHeaders().add("Access-Control-Allow-Origin", "*");
  response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
  response.getHeaders().add("Access-Control-Allow-Credentials", "true");
  response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD");
  </code></pre>
  
  <p>The settings I set for the Angular 6.0.5 frontend are:</p>
  
  <pre><code>const httpOptions = {
    headers: new HttpHeaders({
      'Content-Type': 'application/json'
    })
  };
  </code></pre>
  
  <p>What must I do to keep alive the session when the frontend and backend URL are both different? Is this a missing CORS setting?</p>