CodeGenieApp / CodeGenieApp/serverless-express
`headers` is always replaced by `multiValueHeaders` with ALB events response
- Ngôn ngữ chính
- JavaScript
- Star
- 5.3k
- Fork
- 674
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
**Context:** upgrading from 3.3.8 to 4.3.11.
`headers` is always replaced by `multiValueHeaders` : https://github.com/vendia/serverless-express/blob/6adac653fe1daf1dd44ff6aa17dbf08f07662173/src/event-sources/aws/alb.js#L40-L54
But according to https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers, it should only happen when the multi-value headers feature is enabled on the target group.
I tried to put back `headers` with a custom `getResponse` mapper :
```javascript
const customResponse = ({ statusCode, body, headers, isBase64Encoded }) => {
return {
statusCode,
body,
headers,
isBase64Encoded,
};
};
```
But then I get :
```javascript
"errorMessage": "eventSource.getRequest is not a function",
"stack": [
"TypeError: eventSource.getRequest is not a function",
" at forwardRequestToNodeServer (/var/task/server.js:41241:37)",
" at /var/task/server.js:40578:9",
" at new Promise ()",
" at proxy (/var/task/server.js:40565:12)",
" at Runtime.handler (/var/task/server.js:40602:12)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
```
So it seems that if `getResponse` is set, `getRequest`has to be set as well. This is not ideal as the request mapper is not exported and cannot be used directly.
I don't know what could be the best solution to address this, but at least allowing to set only `getResponse` mapper should allow us to fix the initial issue.
Sister issue but for API Gateway : https://github.com/vendia/serverless-express/issues/437
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với src/event-sources/aws/alb.js tại phần mã ánh xạ response được liên kết và đọc tài liệu về multi-value headers của AWS ALB. Theo dõi cách getResponse và getRequest được chọn, sau đó xác minh rằng các header đơn giá trị được giữ nguyên khi tính năng bị vô hiệu hóa và rằng có thể sử dụng riêng một mapper getResponse tùy chỉnh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, express, javascript, node.js
- Lĩnh vực
- api, backend, cloud
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100