Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 38a0a70

Browse files
committed
fix: don't add empty body to Request
1 parent 9ffc2b5 commit 38a0a70

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/v2/api.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ export type V2Function = { default: (req: Request, context: Context) => Promise<
1010

1111
export const getV2Handler = async (func: V2Function, event: HandlerEvent) => {
1212
const headers = fromEventHeaders(event.headers)
13+
const body = event.body === '' ? undefined : event.body
1314
const req = new Request(event.rawUrl, {
14-
body: event.body,
15+
body,
1516
headers,
1617
method: event.httpMethod,
1718
})
@@ -22,10 +23,10 @@ export const getV2Handler = async (func: V2Function, event: HandlerEvent) => {
2223
cookies.apply(res)
2324

2425
const responseHeaders = headersToObject(res.headers)
25-
const body = await res.text()
26+
const responseBody = await res.text()
2627

2728
return {
28-
body,
29+
body: responseBody,
2930
headers: responseHeaders,
3031
statusCode: res.status,
3132
}

test/helpers/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const invokeLambda = (handler, { method = 'GET', ...options } = {}) => {
22
const event = {
33
...options,
4+
body: options.body ?? '',
45
headers: {
56
...options.headers,
67
},

0 commit comments

Comments
 (0)