fix(nitro): do not modify event.request for worker entries (#1279)

This commit is contained in:
Ahad Birang 2021-10-20 14:24:02 +03:30 committed by GitHub
parent 7df4590d77
commit ffb05fc734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -17,9 +17,9 @@ async function handleEvent (event) {
} }
const url = new URL(event.request.url) const url = new URL(event.request.url)
let body
if (requestHasBody(event.request)) { if (requestHasBody(event.request)) {
event.request.body = await useRequestBody(event.request) body = await useRequestBody(event.request)
} }
const r = await localCall({ const r = await localCall({
@ -30,7 +30,7 @@ async function handleEvent (event) {
headers: event.request.headers, headers: event.request.headers,
method: event.request.method, method: event.request.method,
redirect: event.request.redirect, redirect: event.request.redirect,
body: event.request.body body
}) })
return new Response(r.body, { return new Response(r.body, {

View File

@ -16,8 +16,9 @@ addEventListener('fetch', (event: any) => {
}) })
async function handleEvent (url, event) { async function handleEvent (url, event) {
let body
if (requestHasBody(event.request)) { if (requestHasBody(event.request)) {
event.request.body = await useRequestBody(event.request) body = await useRequestBody(event.request)
} }
const r = await localCall({ const r = await localCall({
@ -28,7 +29,7 @@ async function handleEvent (url, event) {
headers: event.request.headers, headers: event.request.headers,
method: event.request.method, method: event.request.method,
redirect: event.request.redirect, redirect: event.request.redirect,
body: event.request.body body
}) })
return new Response(r.body, { return new Response(r.body, {