https://github.com/mrdaano/follow-url-redirects
With this Node JS package you can follow all redirects from a given url
https://github.com/mrdaano/follow-url-redirects
follow http https redirect redirecting-requests redirecting-urls redirects url
Last synced: about 1 year ago
JSON representation
With this Node JS package you can follow all redirects from a given url
- Host: GitHub
- URL: https://github.com/mrdaano/follow-url-redirects
- Owner: mrdaano
- Created: 2020-04-21T15:52:54.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T20:16:40.000Z (over 3 years ago)
- Last Synced: 2025-03-22T00:44:13.950Z (over 1 year ago)
- Topics: follow, http, https, redirect, redirecting-requests, redirecting-urls, redirects, url
- Language: JavaScript
- Homepage:
- Size: 152 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Follow url redirects
[](https://www.npmjs.com/package/follow-url-redirects)
[](https://github.com/mrdaano/follow-url-redirects/actions)
With this Node JS package you can follow all redirects from a given url.
## Example
In this example, a bit.ly link has been created that will eventually lead to google.com.
```javascript
const followUrlRedirects = require('follow-url-redirects');
followUrlRedirects('https://bit.ly/3cScyDF').then(result => console.log(result));
```
This example returns the following result:
```json
[
{
"url": "https://bit.ly/3cScyDF",
"code": 301,
"cookies": {},
"queryParams": {}
},
{
"url": "http://google.com/",
"code": 301,
"cookies": {},
"queryParams": {}
},
{
"url": "http://www.google.com/",
"code": 200,
"cookies": {},
"queryParams": {}
}
]
```
## Extra options
There is also the possibility to add extra options as a 2nd parameter.
| Option | Default | Description |
|--------|---------|-------------|
| timeout | 10000(ms) | When a request takes too long it stops. In this case after 10 seconds |
| maxRedirects | 10 | The maximum number of redirects. |
### Example with options
```javascript
const followUrlRedirects = require('follow-url-redirects');
const options = {
timeout: 3 * 1000, // 3 seconds
maxRedirects: 5
};
followUrlRedirects('https://bit.ly/3cScyDF', options).then(result => console.log(result));
```