Skip to content

Commit

Permalink
fix(nitro): do not modify event.request for worker entries (#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored Oct 20, 2021
1 parent 06e380f commit cc9a4cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/runtime/entries/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ async function handleEvent (event) {
}

const url = new URL(event.request.url)

let body
if (requestHasBody(event.request)) {
event.request.body = await useRequestBody(event.request)
body = await useRequestBody(event.request)
}

const r = await localCall({
Expand All @@ -30,7 +30,7 @@ async function handleEvent (event) {
headers: event.request.headers,
method: event.request.method,
redirect: event.request.redirect,
body: event.request.body
body
})

return new Response(r.body, {
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/entries/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ addEventListener('fetch', (event: any) => {
})

async function handleEvent (url, event) {
let body
if (requestHasBody(event.request)) {
event.request.body = await useRequestBody(event.request)
body = await useRequestBody(event.request)
}

const r = await localCall({
Expand All @@ -28,7 +29,7 @@ async function handleEvent (url, event) {
headers: event.request.headers,
method: event.request.method,
redirect: event.request.redirect,
body: event.request.body
body
})

return new Response(r.body, {
Expand Down

0 comments on commit cc9a4cd

Please sign in to comment.