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

Forwarding to multiple endpoints #1549

Closed
gravyTrainee opened this issue Sep 1, 2021 · 1 comment
Closed

Forwarding to multiple endpoints #1549

gravyTrainee opened this issue Sep 1, 2021 · 1 comment

Comments

@gravyTrainee
Copy link

Hello!

I'd like to use this wonderful proxy library to forward a request to multiple different endpoints. My plan is to create an altered-source version of the library and do something like this:

    if(options.forward) {
      var forwards = Array.isArray(options.forward) ? options.forward : [options.forward]; // added this...
      for (var forward of forwards) { // ...and this loop
        // If forward enable, so just pipe the request
        var forwardReq = (options.forward.protocol === 'https:' ? https : http).request(
          common.setupOutgoing(options.ssl || {}, options, req, 'forward')
        );

        // error handler (e.g. ECONNRESET, ECONNREFUSED)
        // Handle errors on incoming request as well as it makes sense to
        var forwardError = createErrorHandler(forwardReq, forward);
        req.on('error', forwardError);
        forwardReq.on('error', forwardError);

        (options.buffer || req).pipe(forwardReq);
      }
      if(!options.target) { return res.end(); }
    }

Questions:

  • Is it possible to do this without creating an altered-source version?
  • If not, would you accept a pull request?
@gravyTrainee gravyTrainee changed the title Forwarding to multiple domains Forwarding to multiple endpoints Sep 1, 2021
@gravyTrainee
Copy link
Author

Pull request created, #1550

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

1 participant