Running 'setHeader' during 'proxyReq' event fails for POST requests
Created by: cdl
Right now, it looks like trying to do a setHeader
on the passed in proxyReq
for POST
requests fails. (see below:)
proxy.on('proxyReq', function(proxyReq, req, res, options) {
proxyReq.setHeader('origin', 'https://example.com');
});
The following error is thrown when the above tries to execute:
Error: Can't set headers after they are sent.
This seems to work totally fine for GET
requests, just not POST
requests. Managed to hack around it at first by wrapping the .setHeader
call in check to make sure proxyReq._header
was null
, but it looks like that totally fails when Firefox tries to perform a POST
request (the header doesn't get set).
The same thing appears to happen when trying to do res.setHeader
, as suggested by #819.