AWS API Gateway behind CloudFront, forwarding headers?

Question:

I have an API Gateway that is one of many origins behind a CloudFront distribution that I created. I am trying to forward certain headers to origins (Host, Origin, among others). When I do not forward any headers, the requests reach the API Gateway just fine. However, as soon as I enable header forwarding in the CloudFront distribution (either All or Whitelist) the API Gateway is no longer able to handle the requests. I get the following error:

Any advice on fixing this problem?

Answer:

As commented above, you can’t forward the Host header to the API Gateway origin. Without the Host header, API Gateway doesn’t know what API is being invoked.

Leave a Reply