Replies: 1 comment 1 reply
-
Related to this thread: #318 Probably easiest way is to create a separate middleware and put it before the proxy middleware: const manipulate = async (req, res, next) => {
await registerService(req, res);
next();
}
app.use('/', manipulate, createProxyMiddleware(...)); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm manipulating the request (using onProxyReq) performing the following steps:
When I'm trying to update the proxy request's header it fails due:
Cannot set headers after they are sent to the client
My current code looks like this:
Also if I try to just update the body (and forget about the headers), the error changes to:
ERR_STREAM_WRITE_AFTER_END
meaning the connection is already closed.I'm doing something wrong? Otherwise, what is the point of enabling the request to be manipulated if you won't wait for the manipulation to happen?
Edit: the fixRequestBody function is https://github.com/chimurai/http-proxy-middleware/blob/master/src/handlers/fix-request-body.ts#L8
Beta Was this translation helpful? Give feedback.
All reactions