Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway remove response headers

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?

like image 907
sonja221 Avatar asked Mar 21 '19 20:03

sonja221


1 Answers

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.

like image 99
Chris Williams Avatar answered Sep 18 '22 13:09

Chris Williams