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
In our application there are two independant places where the request body needs to be accessed. In one place we are reading it as json, in the other we are forwarding the whole request with the proxy middleware.
In oak 12 the following would work for the direct access and still allow proxy to use the body.
For oak 14.2.0 I tried using const stream = context.request.body.stream, but this just leads to the error:
TypeError: ReadableStream is locked or disturbed
Before diving into the new code myself, I wanted to ask whether there is a known way to read the request body, while still keeping it intact for the proxy middleware?
Btw. oak@14.2.0 seems to be missing the v in front of the version ;-)
The text was updated successfully, but these errors were encountered:
Unfortunately this does not seem possible from the outside with the current code. Can we somehow get the old behaviour back?
For compatibility with the old version it would make sense to use .tee() in get stream(), but maybe the side-effect is not wanted anymore?
Alternatively I could imagine a new method .teeStream that duplicates the stream.
What do you think @kitsonk ? I'd be happy to create a PR.
I think we can solve this use case, by allowing proxy to work, after the body has been consumed.
If Body has a method that returns #memo and stream as a fallback, this value can be used as BodyInit in the proxy middleware.
In our application there are two independant places where the request body needs to be accessed. In one place we are reading it as json, in the other we are forwarding the whole request with the
proxy
middleware.In oak 12 the following would work for the direct access and still allow proxy to use the body.
For oak 14.2.0 I tried using
const stream = context.request.body.stream
, but this just leads to the error:Before diving into the new code myself, I wanted to ask whether there is a known way to read the request body, while still keeping it intact for the
proxy
middleware?Btw. oak@14.2.0 seems to be missing the
v
in front of the version ;-)The text was updated successfully, but these errors were encountered: