whenever I am trying to add response headers, the CloudFront throws me the
ERROR Validation error: Lambda function result failed validation, the function tried to delete read-only header, headerName : Content-Length.
ERROR Validation error: Lambda function result failed validation, the function tried to delete read-only header, headerName : Content-Encoding.
const response = {
status: '302',
statusDescription: 'Found',
headers: {
'location': [{
key: 'location',
value: 'https://abc.test.io'
}],
'set-cookie': [{
key: 'set-cookie',
value: 'sessiontoken='+sessionObjectData.session.sessionId+'; Secure; HttpOnly'
}]
}
}
callback(null, response)
Can someone let me know what I am doing wrong here ? BTW, I am using viewer-response event