HTTP and HTTPS modules that follow redirects.
Drop in replacement for Nodes
https that automatically follows redirects.
var http = http;var https = https;http;
By default the number of redirects is limited to 5, but you can modify that globally or per request.
maxRedirects = 10; // Has global affect (be careful!)https;
You can inspect the redirection chain from the
fetchedUrls array on the
The array is populated in reverse order, so the original url you requested will be the
last element, while the final redirection point will be at index 0.
Due to the way
XMLHttpRequest works, the
browserify versions of
https already follow redirects.
If you are only targetting the browser, then this library has little value for you. If you want to write cross
platform code for node and the browser,
follow-redirects provides a great solution for making the native node
modules behave the same as they do in browserified builds in the browser. To avoid bundling unnecessary code
you should tell browserify to swap out
follow-redirects with the standard modules when bundling.
To make this easier, you need to change how you require the modules:
var http = ;var https = ;
You can then replace
follow-redirects in your browserify configuration like so:
"browser":"follow-redirects/http" : "http""follow-redirects/https" : "https"
browserify-http module has not kept pace with node development, and no long behaves identically to the native
module when running in the browser. If you are experiencing problems, you may want to check out
browserify-http-2. It is more actively maintained and
attempts to address a few of the shortcomings of
browserify-http. In that case, your browserify config should
look something like this:
"browser":"follow-redirects/http" : "browserify-http-2/http""follow-redirects/https" : "browserify-http-2/https"
Pull Requests are always welcome. Please file an issue
detailing your proposal before you invest your valuable time. Additional features and bug fixes should be accompanied
by tests. You can run the test suite locally with a simple
npm test command.
follow-redirects uses the excellent debug for logging. To turn on logging
set the environment variable
DEBUG=follow-redirects for debug output from just this module. When running the test
suite it is sometimes advantageous to set
DEBUG=* to see output from the express server as well.
Olivier Lalonde (email@example.com)
James Talmage (firstname.lastname@example.org)