fastify-reply-from
fastify-reply-from copied to clipboard
Support using undici behind a proxy server
🚀 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'
}
});
This would be amazing! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
Sure, will send it soon!