title: XMLHttpRequest error in flutter web [Enabling CORS AWS API gateway]
body: <p><strong>Note: It turns out that this had nothing to do with flutter and everything to do with the fact that I had set the API gateway to a Lambda Proxy</strong></p>
  <p>I am trying to hit an API endpoint from a Flutter web application, every time it errors out and gives me the following error.</p>
  <blockquote>
  <p>Error getting sensor data: DioError [DioErrorType.RESPONSE]:
  XMLHttpRequest error.</p>
  </blockquote>
  <p>I know there are several questions here on SO(like <a href="https://stackoverflow.com/questions/56209073/how-to-fix-flutter-web-http-error-making-http-request-to-a-particalar-web-server">this</a> and <a href="https://stackoverflow.com/questions/57765054/enable-cors-while-an-xmlhttprequest-error-occurs-in-flutter-web">this</a>) discussing this issue and the solution seems to be to enable CORS support on the server-side. I am using the AWS API gateway to build the API, I followed <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html#how-to-cors-console" rel="noreferrer">these</a> instructions to enable CORS support from my API. Here are my CORS setting from the API gateway console.</p>
  <p><a href="https://i.stack.imgur.com/x3Yz5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/x3Yz5.png" alt="enter image description here" /></a></p>
  <p>The text in the &quot;Access-Control-Allow-headers&quot; is</p>
  <blockquote>
  <p>'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'</p>
  </blockquote>
  <p>Enabling CORS on the API gateway didn't seem to help, I am still getting the same error on my flutter web app when I try to hit an API.</p>
  <p>The funny thing is, the API work perfectly fine if I hit the API from chrome (i.e. pasting the API URL on the browser and hitting enter). It only fails when I try to hit the API from the flutter web app.</p>
  <p>Question: How do I enable CORS support in my API gateway so my flutter web app can use the API ?</p>