title: API Gateway CORS HTTP 415
body: <p>Okay, I've been all over these interwebs looking for some insight to my issue; I've probably been through over 80 stack overflow threads RE api gateway and such, but none of them seem to help or speak close enough to my issue.</p>
  
  <p>I'm new to API Gateway and cors, but lets see if i can articulate the issue that i am seeing:</p>
  
  <p>Setting up a API gateway proxy to Kinesis firehose hydrating a redshift database. The proxy, firehose, and redshift gateway are up and working when called in isolation, but when called from one of our customer sites, we get an error as follows:</p>
  
  <pre><code>XMLHttpRequest cannot load [api_call_here]. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin [origin_website_here] is therefore not allowed access. The response had HTTP status code 403.
  </code></pre>
  
  <p>Okay, so that strongly implies that CORS is needed, right? in the console on the resource, enable cors, deploy, new error:</p>
  
  <pre><code>XMLHttpRequest cannot load [api_call_here]. Request header field $cookies is not allowed by Access-Control-Allow-Headers in preflight response.
  </code></pre>
  
  <p>Ooooooooookay, from the new OPTIONS method added by the enable CORS feature, in integration response, allowed headers, under access control allowed headers add '$Cookies', deploy.</p>
  
  <p>Now i get a new error, very similar to the first error:</p>
  
  <pre><code>XMLHttpRequest cannot load [api_call_here]. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin [origin_website_here] is therefore not allowed access. The response had HTTP status code 415.
  </code></pre>
  
  <p>Notice the first error had HTTP status code 403, and this third one has status code 415. This is where I'm having issues. If I go into the GET method acting as the proxy method, body mapping templates, I have "When there are no templates defined (recommended)" selected.</p>
  
  <p>Now, I read that when API gateway fails to find a matching template it rejects with a 415 error, so I changed aforementioned option to "When no template matches the request Content-Type header". That made the error disappear, but the data is still not being persisted to redshift when called from the origin. Again, when I call the api directly from postman, insomnia or just a plain old address bar, the records are added nicely.</p>
  
  <p>Opening up chrome and looking at the header i see that the cookie is coming across as text/html. </p>
  
  <p>Regarding the template mapping up there, i have only defined a map for application/json; could that be part of the problem?</p>
  
  <p>Also, the response header as viewed from chrome's console is as follows:</p>
  
  <pre><code>content-length:37
  content-type:application/json
  date:Wed, 19 Apr 2017 23:43:35 GMT
  status:415
  via:1.1 [blahblabbleblah].cloudfront.net (CloudFront)
  x-amz-cf-id:[blahblabbleblah]
  x-amzn-requestid:[blahblabbleblah]
  x-cache:Error from cloudfront
  </code></pre>
  
  <p>I'm relatively new to this so i dont see how cloudfront fits in with this, especially give that it is complaining about media type while the console is complaining about no access-control-allow-origin header.</p>
  
  <p>At any rate, any help as to how to resolve the third error would be most appreciated.</p>