Skip to content

Commit

Permalink
fix(cloudflare): pass raw body instead of parsing it (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendonmatos authored Nov 7, 2022
1 parent 5453805 commit 837f894
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/runtime/entries/cloudflare-pages.ts
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/entries/cloudflare.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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({
Expand Down

0 comments on commit 837f894

Please sign in to comment.