9
votes

I have created an API using AWS api gateway which contains a mock endpoint /test.

In my response, I get the headers x-amzn-RequestId and x-amz-apigw-id. In case of an error, e.g. using a non existing endpoint /test2, I also get the x-amazn-ErrorType header.

I don't want these aws headers to be in my api response. How can these be removed?

1
There are workarounds to eliminate these, but others may appear as a side effect. Why do you want these removed? - Michael - sqlbot
Michael do you have some documentation for this please? Our API consumer has specified what headers they expect, so we need a way to remove these spurious x-amzn headers please. - Peter
Have added solution, let me know if you need any more info - Chris Williams

1 Answers

2
votes

Add CloudFront in front of your API Gateway. Then add a Lambda@Edge function for either origin response or viewer response to remove these attributes from the array.