CodeGenieApp / CodeGenieApp/serverless-express

Lambda@Edge origin response event errors out with 502 error because read-only header was deleted

未关闭
#369 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
JavaScript
星标
5.3k
派生
676
PR 合并指标
30 天内没有已合并 PR

描述

The Cloudfront request responds with:
```The Lambda function result failed validation: The function tried to add, delete, or change a read-only header. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.```

From CloudWatch logs:
```ERROR Validation error: Lambda function result failed validation, the function tried to delete read-only header, headerName : Transfer-Encoding.```

I've figured out a workaround that is to just copy the header manually, but I wonder if the library should've taken care of that itself?

```js
import { getCurrentInvoke } from '@vendia/serverless-express';

router.get('/*', (req, res) => {
const { event } = getCurrentInvoke();

if (event.Records[0].cf.response.headers['transfer-encoding']) {
res.setHeader(
'Transfer-Encoding',
event.Records[0].cf.response.headers['transfer-encoding'][0].value,
);
}
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。