Lambda@Edge function result failed validation

Viewed 15

I have a lambda@edge in Viewer Request that is generating this error:

ERROR Validation error: Lambda function result failed validation, the function tried to add read-only header, headerName : Transfer-Enoding.

I tried to return this event in case of redirection:

const response = {
      status: '301',
      statusDescription: 'Found',
      headers: {
            'location': [{
                key: 'location',
                value: 'https://test.com'
            }]
      }
  }
callback(null, response)

I also tried keeping the same event but I get the same error

const response = event.Records[0].cf.response;
response.status = 301;
response.statusDescription = 'Found';
response.headers['location'] = [{ key: 'Location', value:'https://www.test.com'}];

Cqn someone tells me how to fix this ?

PS: Even requests that pass by this lambda and doesnt verify the redirection condition result in this error also.

0 Answers
Related