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!!

Pascual
preguntada hace un año509 visualizaciones
1 Respuesta
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
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas