Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit ba7b737

Browse files
committed
[web-incoming] fix header modification with agent
This PR ensures that the headers have been modified before the original request is piped into the proxyReq.
1 parent a3fe02d commit ba7b737

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lib/http-proxy/passes/web-incoming.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,6 @@ module.exports = {
127127
common.setupOutgoing(options.ssl || {}, options, req)
128128
);
129129

130-
// Enable developers to modify the proxyReq before headers are sent
131-
proxyReq.on('socket', function(socket) {
132-
if(server) { server.emit('proxyReq', proxyReq, req, res, options); }
133-
});
134-
135130
// allow outgoing socket to timeout so that we could
136131
// show an error page at the initial request
137132
if(options.proxyTimeout) {
@@ -165,6 +160,10 @@ module.exports = {
165160
}
166161
}
167162

163+
// Enable developers to modify the proxyReq before headers are sent
164+
if(server)
165+
server.emit('proxyReq', proxyReq, req, res, options);
166+
168167
(options.buffer || req).pipe(proxyReq);
169168

170169
proxyReq.on('response', function(proxyRes) {

0 commit comments

Comments
 (0)