You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use openapi-fetch in a Next.js 14 app and I've noticed the body is being omitted from POST requests made from within server functions and RSCs. Specifically, prior to calling new CustomRequest(), requestInit.body contains the expected serialized/stringified object, however it's missing from the request instance that's created.
Admittedly, I haven't tried this in a different framework yet, so I'm not entirely sure whether this could be related to Next.js at this point. I just wanted to include that context in case it helps.
Reproduction
Make a POST request from a server function or RSC and observe the API request will be made without a body.
Expected result
Fetch requests containing a body that are made via openapi-fetch should pass the serialized data to the API as a standard fetch request would.
@kerwanp After digging some more, my issue seems to be related to how fetch is called in my app. Before using openapi-fetch, I had been passing body as a part of the options object that's given to fetch (e.g. fetch(url, options)). I noticed that openapi-fetch is creating a Request and passing that to fetch instead (e.g. fetch(Request)). I'm wondering if the API (Azure Logic Apps) that's being called by my app isn't able to read the body/stream when the Request instance is used by fetch.
I recognize it doesn't exist today, but would it be feasible in the future to pass the options directly to fetch as the second arg instead of creating a request and passing that to fetch in cases where a custom Request isn't specified when the client is created? I don't know how common it is for APIs to be unable to read the body when it's a ReadableStream.
openapi-fetch version
0.13.4
Description
I'm trying to use openapi-fetch in a Next.js 14 app and I've noticed the
body
is being omitted fromPOST
requests made from within server functions and RSCs. Specifically, prior to callingnew CustomRequest()
,requestInit.body
contains the expected serialized/stringified object, however it's missing from therequest
instance that's created.Admittedly, I haven't tried this in a different framework yet, so I'm not entirely sure whether this could be related to Next.js at this point. I just wanted to include that context in case it helps.
Reproduction
Make a
POST
request from a server function or RSC and observe the API request will be made without abody
.Expected result
Fetch requests containing a
body
that are made via openapi-fetch should pass the serialized data to the API as a standard fetch request would.Extra
The text was updated successfully, but these errors were encountered: