follow-redirects is a Node.js utility that provides a drop-in replacement for the native `http` and `https` modules, automatically handling HTTP and HTTPS redirects transparently. Currently stable at version 1.16.0, the package sees regular maintenance with patch and minor releases, indicating active development and bug fixes. Its core functionality enables developers to make network requests without manually inspecting and reissuing requests for 3xx status codes, simplifying client-side HTTP interactions significantly. Unlike the built-in Node.js modules, `follow-redirects` abstracts away the complexity of redirect chains, offering a more robust and developer-friendly experience for fetching resources across multiple redirects. It provides configurable limits for maximum redirects and response body length, which can be set both globally for all requests or individually for specific requests.
npm install follow-redirectsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic GET and POST requests using `follow-redirects`, showing how to retrieve the final URL after redirects and how to configure both global and per-request options for maximum redirects and body length.
Increase `maxRedirects` in your options if legitimate redirects exceed the default, or investigate the target URL for misconfigurations causing excessive redirects.
Increase `maxBodyLength` in your options if you legitimately need to send larger request bodies, or ensure your request body size is within limits.
Always use per-request options (`options.maxRedirects`, `options.maxBodyLength`) when specific limits are required, or when running in an environment where other parts of the application might use `follow-redirects` with different expectations.
If you need both the original and final URLs, capture the initial request URL before making the call.
Inspect the URL chain for infinite redirects or increase the `maxRedirects` option if a higher number of legitimate redirects is expected (e.g., `options.maxRedirects = 30;`).
Reduce the size of the request body, or increase the `maxBodyLength` option if larger payloads are necessary (e.g., `options.maxBodyLength = 50 * 1024 * 1024;` for 50MB).
Ensure your project is configured for CommonJS, or use dynamic `import()` if you absolutely need to load `follow-redirects` in an ESM context, though its primary API is CommonJS-oriented.
No dependency data recorded yet.