Menu

Following Redirect Chains That Break Link Previews: Cap the Hops, Prefer Absolute Location Headers, and Read the Final HTML
📰

Following Redirect Chains That Break Link Previews: Cap the Hops, Prefer Absolute Location Headers, and Read the Final HTML

DEV Community: node·Abid Ali·1 day ago
#3feoGIUW
#devtonodejs#devto#dev#html#tags
Reading 0:00
15s threshold

A page can look perfect in the browser and still share as the wrong card. The usual suspect is a redirect. The address in the chat is not the address that answers with the Open Graph tags. Something in the middle returns a Location header, the crawler follows it, and the tags it finds belong to a different page — the old URL, the bare domain, a login wall, or a soft 404 that still says 200.

This post is a practical walk through that problem in Node.js. You will get a small helper that follows a redirect chain with a hop limit, prefers absolute Location values, refuses private network targets, and prints the final share tags. You will also get a short checklist for when a card keeps showing the wrong title after a move.

I built OG Scope as a set of free tools for this kind of check. The redirect checker follows a URL hop by hop and shows each status code and the final page.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.