title: AWS API Gateway Response Headers Missing With VPC HTTP Proxy
body: <p>I'm working on creating an AWS API Gateway with a VPC integration that proxies to another internal service.  This is a POST request.  The proxy service responds as expected in a UI that calls the service directly with the correct headers attached.  </p>
  
  <p>Interestingly, when I call the service using AWS Amplify, the preflight check and POST are successful <em>and</em> the reponse body looks perfect.  But I'm getting a generic "Network Error" from Amplify (via axios library).  Chrome logs this error to the console:  <code>Failed to load https://my-amazon-api-url/thing: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
  </code>
  I'm unsure as to why that header is not in the response and I can't seem to find a way to get it on the reponse.  NOTE: the proxied service returns a 201 with a response body.  I <em>think</em> that may have something to do with it, but I'm unsure.</p>
  
  <p><strong>Preflight Headers</strong></p>
  
  <p>RESPONSE HEADERS:</p>
  
  <pre><code>accept-encoding: gzip, deflate, br
  access-control-allow-credentials: true
  access-control-allow-headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,Access-Control-Allow-Origin
  access-control-allow-methods: POST,OPTIONS
  access-control-allow-origin: *
  access-control-expose-headers: Access-Control-Allow-Origin
  content-length: 0
  content-type: application/json
  date: Wed, 20 Jun 2018 17:30:10 GMT
  status: 200
  x-amz-apigw-id: someId
  x-amzn-requestid: someID
  </code></pre>
  
  <p><strong>POST Headers</strong></p>
  
  <p>REQUEST HEADERS: </p>
  
  <pre><code>:authority: someAmazonUrl
  :method: POST
  :path: /thing
  :scheme: https
  accept: application/json, text/plain, */*
  accept-encoding: gzip, deflate, br
  accept-language: en-US,en;q=0.9
  access-control-allow-origin: *
  authorization: AWS4-HMAC-SHA256 Credential=someCredentials, SignedHeaders=access-control-allow-origin;content-type;host;x-amz-date;x-amz-security-token, Signature=aSignature
  cache-control: no-cache
  content-length: 559
  content-type: application/json
  dnt: 1
  origin: http://localhost:8080
  pragma: no-cache
  referer: http://localhost:8080/
  user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
  x-amz-date: 20180620T173010Z
  x-amz-security-token: aReallyLongToken
  </code></pre>
  
  <p>REPONSE HEADERS:</p>
  
  <pre><code>content-encoding: gzip
  content-length: 463
  content-type: application/json; charset=utf-8
  date: Wed, 20 Jun 2018 17:30:10 GMT
  status: 201
  x-amz-apigw-id: agatewayId
  x-amzn-remapped-connection: keep-alive
  x-amzn-remapped-content-length: 866
  x-amzn-remapped-date: Wed, 20 Jun 2018 17:30:10 GMT
  x-amzn-requestid: aLongId
  </code></pre>
  
  <p><strong>Swagger JSON for the specific route</strong></p>
  
  <pre><code>"/thing": {
        "post": {
          "operationId": "PostThing",
          "consumes": [
            "application/json"
          ],
          "produces": [
            "application/json"
          ],
          "parameters": [
            {
              "name": "Access-Control-Allow-Origin",
              "in": "header",
              "required": false,
              "type": "string"
            },
            {
              "name": "Content-Type",
              "in": "header",
              "required": false,
              "type": "string"
            },
            {
              "name": "Accept-Encoding",
              "in": "header",
              "required": false,
              "type": "string"
            },
            {
              "in": "body",
              "name": "ThingPostBody",
              "required": true,
              "schema": {
                "$ref": "#/definitions/ThingPostBody"
              }
            }
          ],
          "responses": {
            "200": {
              "description": "200 response",
              "headers": {
                "Access-Control-Allow-Origin": {
                  "type": "string"
                }
              }
            },
            "201": {
              "description": "201 response",
              "headers": {
                "Access-Control-Allow-Origin": {
                  "type": "string"
                },
                "Content-Encoding": {
                  "type": "string"
                },
                "Accept-Encoding": {
                  "type": "string"
                },
                "Content-Type": {
                  "type": "string"
                }
              }
            },
            "400": {
              "description": "400 response",
              "headers": {
                "Access-Control-Allow-Origin": {
                  "type": "string"
                }
              }
            },
            "401": {
              "description": "401 response",
              "headers": {
                "Access-Control-Allow-Origin": {
                  "type": "string"
                }
              }
            },
            "403": {
              "description": "403 response",
              "headers": {
                "Access-Control-Allow-Origin": {
                  "type": "string"
                }
              }
            }
          },
          "x-amazon-apigateway-integration": {
            "uri": "http://internal-amazon-url/thing",
            "responses": {
              "default": {
                "statusCode": "201",
                "responseParameters": {
                  "method.response.header.Access-Control-Allow-Origin": "'*'"
                }
              }
            },
            "requestParameters": {
              "integration.request.header.Access-Control-Allow-Origin": "'*'"
            },
            "passthroughBehavior": "when_no_match",
            "connectionType": "VPC_LINK",
            "connectionId": "someID",
            "httpMethod": "POST",
            "type": "http_proxy"
          }
        },
        "options": {
          "consumes": [
            "application/json"
          ],
          "produces": [
            "application/json"
          ],
          "responses": {
            "200": {
              "description": "200 response",
              "headers": {
                "Access-Control-Expose-Headers": {
                  "type": "string"
                },
                "Access-Control-Allow-Origin": {
                  "type": "string"
                },
                "Access-Control-Allow-Methods": {
                  "type": "string"
                },
                "Accept-Encoding": {
                  "type": "string"
                },
                "Access-Control-Allow-Headers": {
                  "type": "string"
                },
                "Content-Type": {
                  "type": "string"
                }
              }
            }
          },
          "x-amazon-apigateway-integration": {
            "responses": {
              "2\\d{2}": {
                "statusCode": "200",
                "responseParameters": {
                  "method.response.header.Access-Control-Expose-Headers": "'Access-Control-Allow-Origin,Content-Type,Content-Encoding'",
                  "method.response.header.Access-Control-Allow-Methods": "'POST,OPTIONS'",
                  "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,Access-Control-Allow-Origin'",
                  "method.response.header.Access-Control-Allow-Origin": "'*'",
                  "method.response.header.Accept-Encoding": "'gzip, deflate, br'"
                }
              }
            },
            "requestTemplates": {
              "application/json": "{\"statusCode\": 200}"
            },
            "passthroughBehavior": "when_no_templates",
            "type": "mock"
          }
        }
      }
  </code></pre>