Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

follow-redirects 1.15.4

HTTP and HTTPS modules that follow redirects.
Package summary
Share
0
issues
0
licenses
Package created
15 Nov 2012
Version published
30 Dec 2023
Maintainers
2
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does follow-redirects do?

Follow-Redirects is a drop-in replacement for Node's http and https modules providing automatic redirection following features. It's an incredibly useful package when you want your HTTP or HTTPS request methods to seamlessly follow redirects without any additional coding required.

How do you use follow-redirects?

Follow-Redirects is simple to use. Here's a basic usage example:

const { http, https } = require('follow-redirects');

http.get('http://bit.ly/900913', response => {
  response.on('data', chunk => {
    console.log(chunk);
  });
}).on('error', err => {
  console.error(err);
});

In this code, an HTTP GET request is made. If the requested URL redirects to another URL, the request will automatically follow the redirection.

To inspect the final redirected URL, you can use the responseUrl property. Here's an example:

const request = https.request({
  host: 'bitly.com',
  path: '/UHfDGO',
}, response => {
  console.log(response.responseUrl);
  // 'http://duckduckgo.com/robots.txt'
});
request.end();

In this case, the responseUrl will return the final URL where the original URL was redirected to. If no redirection took place, responseUrl will be the original request URL.

Where are the follow-redirects docs?

The comprehensive Follow-Redirects documentation can be found on their GitHub repo. It includes comprehensive details on usage, options, advanced usage, and more, making it easier for users to understand and implement the package accurately.