title: CORS AWS API-Gateway with Authentication Angular2
body: <p>my AWS API-Gateway is configured as Lambda Proxy. In Lambda i added the following Headers:</p>
  
  <pre><code>'Access-Control-Allow-Origin': '*',
  'Access-Control-Allow-Methods': '*',
  'Access-Control-Allow-Headers': 'Content-Type,X-Amz-Date,Authorization,X-Api-Key'
  </code></pre>
  
  <p>First, everythink works fine with it. Now i added an Authorizer with CognitoUserPool and i get the following Error:</p>
  
  <pre><code>XMLHttpRequest cannot load https://xxx.eu-west-1.amazonaws.com/xxx/xxx. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 401.
  </code></pre>
  
  <p>I think the problem is, that with Authentication my Lambdafunction is not invoked and so no Headers were set. I call the Endpoint from an Angular2 Application with</p>
  
  <pre><code>const headers = new Headers();
  headers.append('Authorization', 'authtoken');
  http.get('address...', headers);
  </code></pre>
  
  <p>But the headers were not set/append to the request because of any CORS-reasons i think. </p>
  
  <p>Anyone an idea how can i solve this?</p>
  
  <p>P.S.: I tried the "Enable Cors" feature of API-Gateway but that does not work.</p>
  
  <p>Edit: I also have a "OPTIONS" Method in Gateway with Authentication, that responds with the Headers above.</p>
  
  <p>Greetings</p>