mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nitro): read body stream on post requests for service-worker
(#527)
This commit is contained in:
parent
2c82c27960
commit
13abec6143
@ -3,6 +3,7 @@ import '#polyfill'
|
||||
import { localCall } from '../server'
|
||||
|
||||
const STATIC_ASSETS_BASE = process.env.NUXT_STATIC_BASE + '/' + process.env.NUXT_STATIC_VERSION
|
||||
const METHODS_WITH_BODY = ['POST', 'PUT', 'PATCH']
|
||||
|
||||
addEventListener('fetch', (event: any) => {
|
||||
const url = new URL(event.request.url)
|
||||
@ -15,6 +16,9 @@ addEventListener('fetch', (event: any) => {
|
||||
})
|
||||
|
||||
async function handleEvent (url, event) {
|
||||
if (METHODS_WITH_BODY.includes(event.request.method.toUpperCase()) && !event.request.body) {
|
||||
event.request.body = await event.request.text()
|
||||
}
|
||||
const r = await localCall({
|
||||
event,
|
||||
url: url.pathname,
|
||||
|
Loading…
Reference in New Issue
Block a user