Open omarmhamza opened 2 months ago
I am open for feedback here and any other suggestions on how we can configure these options without this workaround. Thank you.
Did you try to set the follow-redirects
global options in your application?
// https://github.com/follow-redirects/follow-redirects?tab=readme-ov-file#global-options
const followRedirects = require('follow-redirects');
followRedirects.maxRedirects = 10;
followRedirects.maxBodyLength = 20 * 1024 * 1024; // 20 MB
If this works, there is no need to modify HPM
or http-proxy
@chimurai yes I have seen these global options in follow-redirects.
But it is difficult to know why there is these limits if we are using HPM
solely. As a consumer of the library I expected to have these options available to me to configure. But I had to dig around to then know that different http agents are used if followredirect is set and thus certain limits are then applied which were not applied if the option was set to false.
Looking at this again, maybe it would be a better idea to include these options as globals in HPM
or have this documented somewhere giving heads-up to the consumers of this library. What do you think?
This PR fixes this issue 983 by adding additional config options (
followRedirectsOpts
) to configure the maxBodyLength and maxRedirects when followRedirects options is enabled.Description
Under the hood node-proxy uses follow-redirects module when followRedirects is set to true. It does that by using the http and https agents given by follow-redirects module as shown here
A function is added
setFollowRedirectOptions
in the constructor to use the additional optionsfollowRedirectsOpts
:However, the way it is added is not the cleanest, it is done by setting these properties globally for follow-redirects module. I think this is a limitation since there are no options within http-proxy to set these configurations. Moreover, http-proxy is unmaintained and having the a PR there is useless.
Motivation and Context
How has this been tested?
Types of changes
Checklist: