Three ways to see the chain, compared#
We built a fixture with a three-hop chain: localhost/r1 sent 302 to /r2, which sent 301 to 127.0.0.1/r3, a different origin, which sent 302 to /final.
| Tool | What it showed |
|---|---|
| DevTools Network panel with Preserve log on | Each request as its own row, with status and the Location response header |
Playwright, following request.redirectedFrom() from the final response back | All four URLs in order |
performance.getEntriesByType('navigation')[0].redirectCount on the final page | 0, because one redirect crossed origins |
A second chain with two same-origin redirects reported redirectCount as 2. Navigation Timing hides redirect details from the final page when a redirect crossed origins, so a 0 there does not mean the chain was direct. MDN: PerformanceNavigationTiming.redirectCount
Capture it in DevTools#
- Open the Network panel and turn on Preserve log, so the panel keeps requests across the navigation.
- Turn on Disable cache, or note that you left it off. A browser can serve a cached 301 without asking the server, which changes what the chain shows.
- Click the link or load the starting URL.
- For each redirect row, copy the status, the request URL, the
Locationheader and anySet-Cookieheaders.
Chrome DevTools: Network features reference
Capture it outside the browser#
curl shows each hop's headers when it follows redirects:
curl -sS -o /dev/null -D - -L 'https://example.test/promo?ref=mail'
-D - prints each response's headers, and -L follows Location. curl sends no browser cookies unless you give it a cookie jar with -b and -c, so a chain that depends on cookies will differ. That difference is evidence. Replay the request outside the page covers copying the browser's headers.
Capture it in a script#
const response = await page.goto('https://example.test/promo?ref=mail');
const chain = [];
for (let req = response.request(); req; req = req.redirectedFrom()) chain.unshift(req.url());
console.log(chain);
Add (await req.response())?.status() to each entry if the statuses matter. Playwright: request.redirectedFrom()
What to look for in each hop#
- Dropped query parameters. A hop that redirects
/promo?ref=mailto/promo/without the query loses attribution or state. - Scheme and host changes.
httptohttps,wwwto the apex domain and back. Two layers doing opposite rewrites make a redirect loop. - Cookies set on a hop. A cookie set on a redirect response is stored before the next request, if the browser accepts it. Check its
Domain,Path,SecureandSameSite. - Permanent redirects. A 301 or 308 can be cached by the browser, so the reporter's browser may follow an old redirect the server no longer sends.
Worked example: a campaign link that lost its code#
This example is fictional. Marketing reports that a newsletter link lands on the pricing page without the discount banner. The link is https://example.test/go/winter.
The Network panel with Preserve log shows three hops: /go/winter 302 to /pricing?coupon=WINTER, then 301 to https://www.example.test/pricing, then 200. The second hop, a host canonicalization rule at the CDN, rebuilt the URL without its query string. The report gave each hop's status and Location, so the maintainer went straight to the CDN rule rather than the application's link handler.
Questions#
Why does the reporter see a redirect the server no longer sends?
The browser may have cached a 301 or 308. In our fixture, a repeated navigation through a 301 loop made no requests to the server at all. Test in a fresh profile, and clear the site's cached data in the reporter's browser to confirm.
Can JavaScript or meta refresh redirects appear in the chain?
They appear as separate navigations, not as HTTP redirects. With Preserve log on you see each document request; redirectedFrom() and redirectCount do not include them.
Do I need the response bodies?
Rarely. The status and headers decide where the browser goes. A body matters only for a page that redirects with JavaScript.
Return to reproducing what someone else saw for the other layers a replay needs.