Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxyReq.setHeader doesn't seem to work #889

Open
entropitor opened this issue Oct 3, 2015 · 6 comments
Open

proxyReq.setHeader doesn't seem to work #889

entropitor opened this issue Oct 3, 2015 · 6 comments

Comments

@entropitor
Copy link

The example

proxy.on('proxyReq', function(proxyReq, req, res, options) {
  proxyReq.setHeader('X-Special-Proxy-Header', 'foobar');
});

from the readme doesn't seem to work. It just uses the header from the req (or leaves it out if the request header was empty).

@tanaydin
Copy link

Hi there,

It works with my code. There should be something else. I'm using it like..

    proxy.on('proxyReq', function proxyRequestReceiver(proxyRequest, request) {
      var chunks = [];
      request.on('data', function proxyRequestData(chunk) {
        chunks.push(chunk);
      });
      request.on('error', function proxyRequestError() {
        console.log('request on error');
      });
      proxyRequest.setHeader('host', self.host.hostname);
      ...
      ...
   });

@entropitor
Copy link
Author

does this also work with custom headers? And should it be all lower cases? Or should the example in the README work like it's explained there?

@jcrugzz
Copy link
Contributor

jcrugzz commented Oct 31, 2015

In node, headers are automatically lowercased.
https://nodejs.org/api/http.html#http_http

On Sat, Oct 31, 2015 at 10:00 AM, Jens Claes notifications@github.com
wrote:

does this also work with custom headers? And should it be all lower cases?
Or should the example in the README
https://github.com/nodejitsu/node-http-proxy/blob/master/README.md#setup-a-stand-alone-proxy-server-with-proxy-request-header-re-writing
work like it's explained there?


Reply to this email directly or view it on GitHub
#889 (comment)
.

Jarrett Cruger
Software Engineer at GoDaddy https://www.godaddy.com/ Inc.

@entropitor
Copy link
Author

But would it work if you override headers with caps, as is done in the readme and in the description of my issue?

@uicoded
Copy link

uicoded commented Dec 7, 2015

Got to the same point. Blindly trusted README

@mpietruschka
Copy link

@entropitor Does this bug still exist? Meanwhile, do you know why you header hasn't been set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants