Skip to content

Commit 62cfd3c

Browse files
author
Martin Jesper Low Madsen
committed
Makes sure event.body is a string
1 parent b256cc0 commit 62cfd3c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

proxy.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ async function handler(event, context, callback) {
1515
clientContext: JSON.parse(Buffer.from(ClientContext, 'base64')),
1616
};
1717

18+
switch (targetEvent.headers['content-type']) {
19+
case 'application/json':
20+
default:
21+
targetEvent.body = typeof targetEvent.body === 'string' ? targetEvent.body : JSON.stringify(targetEvent.body);
22+
break;
23+
}
24+
1825
// call the target function
1926
return target[targetHandlerFunction](targetEvent, targetContext, (error, response) => {
2027
if (error) {

0 commit comments

Comments
 (0)