Open Graph meta tags are inconsistently missing from instagram post's link response

3.3k Views Asked by At

I am putting link previews in my web app. I'm using nodejs in backend to retrieve og properties (like site_name, description, image, title, etc). Links of YouTube and other stuffs works fine but with Instagram's link, the Open Graph meta tags are missing inconsistently in the response body of the link.

For Example, consider this link: https://www.instagram.com/p/B_hs0pUlRvR/

when I request body of this link in my script running in my local machine, it does consists of the og meta tags. The og: meta tags are present

But when I put the same script in cloud, and perform the same request those meta tags goes missing. Missing og: meta tags

I tried to view the source code of the link in my mobile phone, such kind of strange behavior continues there as well.

no og tags when source code is viewed in normal mode no og tags when source code is viewed in normal mode

og: meta tags are present when source code is viewed in Incognito mode og: meta tags are present when source code is viewed in Incognito mode

I have tried to change user-agent in the request but that didn't helped. What's the reason behind this and how can I get link preview of Instagram post's links succesfully.

1

There are 1 best solutions below

0
Valery Ryaboshapko On

This set of headers seems solves the problem.

Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1