skymethod / denoflare

Develop, test, and deploy Cloudflare Workers with Deno.
https://denoflare.dev
MIT License
706 stars 35 forks source link

Cannot fetch with body in denoflare serve #33

Closed rizrmd closed 1 year ago

rizrmd commented 2 years ago

When I try to fetch using body, e.g.

await fetch("https://site...", {
      "method": "POST",
      "body": JSON.stringify({})
})

throw this:

catch Error: packRequest: init.body
    at packRequest (blob:null/3639bbfb-e6a4-4dca-8f3f-dd8a1a3c8f00:923:48)
    at blob:null/3639bbfb-e6a4-4dca-8f3f-dd8a1a3c8f00:720:22
    at apo (blob:null/09d901da-479f-4908-9df0-1021d32d744e:7:25)
    at serveTitle (blob:null/09d901da-479f-4908-9df0-1021d32d744e:4557:25)
    at async Object.fetch (blob:null/09d901da-479f-4908-9df0-1021d32d744e:4569:28)
    at async ModuleWorkerExecution.fetch (blob:null/3639bbfb-e6a4-4dca-8f3f-dd8a1a3c8f00:584:16)
    at async WorkerExecution.fetch (blob:null/3639bbfb-e6a4-4dca-8f3f-dd8a1a3c8f00:682:16)
    at async blob:null/3639bbfb-e6a4-4dca-8f3f-dd8a1a3c8f00:2619:30
    at async RpcChannel.receiveMessage (blob:null/3639bbfb-e6a4-4dca-8f3f-dd8a1a3c8f00:39:36)
    at async self.onmessage (blob:null/3639bbfb-e6a4-4dca-8f3f-dd8a1a3c8f00:2656:13)
johnspurlock-skymethod commented 1 year ago

Thanks for the report, bodies were working for fetch(Request) but not for the multi-arg overload. I just pushed support for external fetch bodies in commit 631313eeaabed727bbfa0ee944e920b633eabe51, can you test it out locally and verify it works in your worker?

To install denoflare as of a commit instead of a release tag, substitute 631313eeaabed727bbfa0ee944e920b633eabe51 in place of the release tag v0.5.10 however you installed denoflare.

johnspurlock-skymethod commented 1 year ago

Fix included in the latest release v0.5.11