Remove headers Cloudfront automatically includes in the response

0

Hi,

I've got a cloudfront distribution in front of an api that internally sends a request to an endpoint. This request includes the following headers :

user-agent content-length accept accept-encoding cloudfront-forwarded-proto cloudfront-is-desktop-viewer cloudfront-is-mobile-viewer cloudfront-is-smarttv-viewer cloudfront-is-tablet-viewer cloudfront-viewer-asn cloudfront-viewer-country content-type via x-amz-cf-id x-amzn-trace-id x-apigateway-context x-apigateway-event x-forwarded-for x-forwarded-host x-forwarded-port x-forwarded-proto

I need to remove some of them, but I can't find how. I've created a cloudfront policy to remove the x-apigateway-event but I still receive it on the target endpoint. The Api Gateway is configured as a Proxy integration, and the following message appears under "Integrations response":

Proxy integrations cannot be configured to transform responses.

Does it mean I cannot remove some headers the api gateway is including?

Thanks in advance!!

1 Answer
0

You can remove header from Response using a AWS CloudFront Response Headers Policy: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/modifying-response-headers.html

In regards to AWS API Gateway Integration Response message "Proxy integrations cannot be configured to transform responses" means that you cannot modify the response header via AWS API Gateway, you must do it from the Service you're connected to, which is AWS Lambda.

AWS
vtjean
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions