From 801175b5b881a2bc1af4db5da8ad064b08eb41ca Mon Sep 17 00:00:00 2001 From: brendonmatos Date: Thu, 3 Nov 2022 18:42:40 -0300 Subject: [PATCH] fix(cloudflare): raw body instead parsing (unjs#589) --- src/runtime/entries/cloudflare-pages.ts | 4 ++-- src/runtime/entries/cloudflare.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/entries/cloudflare-pages.ts b/src/runtime/entries/cloudflare-pages.ts index 14c00bc42c..a46219ca07 100644 --- a/src/runtime/entries/cloudflare-pages.ts +++ b/src/runtime/entries/cloudflare-pages.ts @@ -1,5 +1,5 @@ import '#internal/nitro/virtual/polyfill' -import { requestHasBody, useRequestBody } from '../utils' +import { requestHasBody } from '../utils' import { nitroApp } from '../app' /** @see https://developers.cloudflare.com/pages/platform/functions/#writing-your-first-function */ @@ -32,7 +32,7 @@ export async function onRequest (ctx: CFRequestContext) { const url = new URL(ctx.request.url) let body if (requestHasBody(ctx.request)) { - body = await useRequestBody(ctx.request) + body = Buffer.from(await ctx.request.arrayBuffer()) } const r = await nitroApp.localCall({ diff --git a/src/runtime/entries/cloudflare.ts b/src/runtime/entries/cloudflare.ts index 202dcdff86..42c53b9965 100644 --- a/src/runtime/entries/cloudflare.ts +++ b/src/runtime/entries/cloudflare.ts @@ -1,7 +1,7 @@ import '#internal/nitro/virtual/polyfill' import { getAssetFromKV, mapRequestToAsset } from '@cloudflare/kv-asset-handler' import { withoutBase } from 'ufo' -import { requestHasBody, useRequestBody } from '../utils' +import { requestHasBody } from '../utils' import { nitroApp } from '../app' import { useRuntimeConfig } from '#internal/nitro' @@ -19,7 +19,7 @@ async function handleEvent (event: FetchEvent) { const url = new URL(event.request.url) let body if (requestHasBody(event.request)) { - body = await useRequestBody(event.request) + body = Buffer.from(await event.request.arrayBuffer()) } const r = await nitroApp.localCall({