diff --git a/src/lib/getBody.ts b/src/lib/getBody.ts index 100a062..9b4826b 100644 --- a/src/lib/getBody.ts +++ b/src/lib/getBody.ts @@ -2,7 +2,11 @@ import type { RequestEvent } from '@sveltejs/kit'; const getBody = async (event: RequestEvent) => { const { request } = event; - return request.headers.get('content-type') === 'application/json' ? request.json() : request.text(); + if (request.body) { + return request.headers.get('content-type') === 'application/json' ? request.json() : request.text(); + } else { + return null; + } }; export { getBody }; diff --git a/src/lib/startServerAndCreatSvelteHandler.ts b/src/lib/startServerAndCreatSvelteHandler.ts index 1bfbb87..a086de7 100644 --- a/src/lib/startServerAndCreatSvelteHandler.ts +++ b/src/lib/startServerAndCreatSvelteHandler.ts @@ -34,7 +34,7 @@ export function startServerAndCreateSvelteKitHandler contextFunction(event), httpGraphQLRequest: { - body: await getBody(event), + body: await getBody(event) ?? '', headers: getHeaders(event), method: request.method, search: new URL(request.url).search || '',