Does fetch support piping body into request?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 880
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
Hello,
I'm trying to create proxy which pass all incoming data into fetch request to an another server, but every try causes error/no success.
Could someone help me?
I'm trying do something like that:
router.post('/test', async (req, res) => {
var r = new stream.PassThrough();
req.pipe(r);
await fetch('http://some-url', {
body: stream.Readable.from(r),
method: 'POST',
headers: req.headers,
});
res.sendStatus(202);
});
or
router.post('/test', async (req, res) => {
await fetch('http://some-url', {
body: req,
method: 'POST',
headers: req.headers,
});
res.sendStatus(202);
});
I need to achieve the same result, as old lib does: https://www.npmjs.com/package/request#streaming
I'm using node 18 and embedded fetch method.
Thanks in advance.
Regards
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing both proxy examples with Node 18's embedded fetch, using the request body streams and headers shown in the issue. Determine whether streaming request bodies are supported; done means establishing the supported behavior and documenting or implementing the required piping behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100