fastify-reply-from icon indicating copy to clipboard operation
fastify-reply-from copied to clipboard

Support using undici behind a proxy server

Open omardoma opened this issue 3 years ago • 2 comments

🚀 Feature Proposal

Add a field in undici options that specifies the proxy you need to connect to before forwarding the request to the upstream.

Motivation

Right now the only way to use the plugin behind a proxy server is to not use undici and instead use http while passing the agents option:

const ReplyFrom = require('fastify-reply-from');
const proxy = require('proxy-agent');
fastify.register(ReplyFrom, {
  http: {
     agents: {
       "http:": proxy('url'),
       "https:": proxy('url')
     }
  }
});

Recently undici has added support for proxies as mentioned in its documentation, so it would be great if we can support passing the proxy field as part of undici's options and not have to switch to http.

Example

const ReplyFrom = require('fastify-reply-from');
fastify.register(ReplyFrom, {
  unidici: {
    proxy: 'http://username:password@proxyIp:proxyPort'
  }
});

omardoma avatar Mar 30 '21 10:03 omardoma

This would be amazing! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

mcollina avatar Mar 30 '21 12:03 mcollina

Sure, will send it soon!

omardoma avatar Apr 13 '21 07:04 omardoma