follow-redirect-url
v2.2.0
Published
A simple command-line utility that lets you follow redirects to see where http URLs end up. Useful for shortened URLs.
Downloads
4,266
Readme
follow-redirect-url
A simple command-line utility that lets you follow redirects to see where http URLs end up. Useful for shortened URLs.
Follows up to 20 redirects Default.
Also added User-Agent header to requests, some web address won't redirect without browsers information eg: https://fb.me
Table of contents
Installation
Install with npm globally (For CLI):
npm install -g follow-redirect-url@latestInstall for your project:
npm install --save follow-redirect-urlVerify install
follow --version
follow doctorUsage
CLI:
follow https://bit.ly/2X7gCIT
follow --version
follow doctorModule:
The first argument is a url string.
'use strict';
const followRedirect = require('follow-redirect-url');
async function main() {
const urls = await followRedirect.startFollowing('https://bit.ly/2X7gCIT');
console.log(urls);
}
main().catch(console.error);Programmatic version:
const { version } = require('follow-redirect-url');
console.log(version);Output
CLI Result:
https://bit.ly/2X7gCIT -> 301
http://github.com/sthnaqvi/follow-redirect-url -> 301
https://github.com/sthnaqvi/follow-redirect-url -> 200Arabic and other Unicode paths are shown percent-encoded in the redirect chain (same as a browser address bar).
Project Result:
[ { url: 'https://bit.ly/2X7gCIT',
redirect: true,
status: 301,
redirectUrl: 'http://github.com/sthnaqvi/follow-redirect-url' },
{ url: 'http://github.com/sthnaqvi/follow-redirect-url',
redirect: true,
status: 301,
redirectUrl: 'https://github.com/sthnaqvi/follow-redirect-url' },
{ url: 'https://github.com/sthnaqvi/follow-redirect-url',
redirect: false,
status: 200 } ]Options
CLI options:
-v,--version,-V— print package version-H "Header: value"— send custom request headersfollow doctor— check for stale duplicate global installs
Module options:
The second argument is an options object. Options are optional.
max_redirect_length- maximum redirection limit. Default:20request_timeout- request timeout in milliseconds. Default:10000ignoreSslErrors- ignore SSL certificate errors when following redirects. Default:false
const followRedirect = require('follow-redirect-url');
const options = {
max_redirect_length: 5,
request_timeout: 5000,
ignoreSslErrors: true
};
async function main() {
const urls = await followRedirect.startFollowing('https://bit.ly/2X7gCIT', options);
console.log(urls);
}
main().catch(console.error);Note: URL fragments (#section) are not part of HTTP redirects and cannot be followed by this tool.
Troubleshooting
Check installed version
follow --version
npm list -g follow-redirect-urlStale global install (wrong version running)
If follow behaves unexpectedly or shows deprecation warnings despite installing the latest version, an old global binary may be shadowing the new one (e.g. /usr/local/bin/follow from an older install).
follow doctor
npm uninstall -g follow-redirect-url --prefix /usr/local
npm install -g follow-redirect-url@latest
hash -r
follow doctorSite returns 403
Some sites use Cloudflare or bot protection. The CLI sends a modern browser User-Agent and Accept-Language by default, but Cloudflare can still block non-browser clients before any HTTP redirect runs.
Example: https://www.mobtada.com/sports/1199729 HTTP-redirects in Chrome to the full Arabic slug URL, but follow may stop at 403 because Cloudflare blocks the request first. This is not a JavaScript-only redirect — the tool does not execute page scripts.
For protected sites, pass cookies or custom headers from your browser:
follow -H "Cookie: your-cookie" https://example.comOr copy the final URL from your browser address bar after it loads.


