CodeGenieApp / CodeGenieApp/serverless-express

`headers` is always replaced by `multiValueHeaders` with ALB events response

Aperta
#464 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
5.3k
Fork
676
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.