title: Access Control Allow Origin issue in Angular 2
body: <p>I have a problem with getting data from my node.js server.</p>
  
  <p>The client side is:</p>
  
  <pre><code>    public getTestLines() : Observable&lt;TestLine[]&gt; {
      let headers = new Headers({ 'Access-Control-Allow-Origin': '*' });
      let options = new RequestOptions({ headers: headers });
  
      return this.http.get('http://localhost:3003/get_testlines', options)
                  .map((res:Response) =&gt; res.json())
                  .catch((error:any) =&gt; Observable.throw(error.json().error || 'Server error')); 
  }
  </code></pre>
  
  <p>in server side I also set the headers:</p>
  
  <pre><code>resp.setHeader('Access-Control-Allow-Origin','*') 
  resp.send(JSON.stringify(results))
  </code></pre>
  
  <p>But I get an error</p>
  
  <blockquote>
    <p>"XMLHttpRequest cannot load <a href="http://localhost:3003/get_testlines" rel="noreferrer">http://localhost:3003/get_testlines</a>.
    Response to preflight request doesn't pass access control check: No
    'Access-Control-Allow-Origin' header is present on the requested
    resource. Origin '<a href="http://localhost:3000" rel="noreferrer">http://localhost:3000</a>' is therefore not allowed
    access."</p>
  </blockquote>
  
  <p>How can I fix it? When I remove headers it says that this header is required. </p>