Problem with Twitter cards and HTTP-to-HTTPS automatic redirect

We have a website at https://optimistic-lamarr-a5fb39.netlify.app (also visible via our domain https://spaceprob.es ) that contains statically-rendered Twitter card metadata in the HTML in the usual way. Our Twitter cards work great with the Twitter Card validator and on Twitter itself.

Our site also has the automatic Netlify-generated redirect from all HTTP URLs to their HTTPS equivalents. When Twitter users hand-write the URL and end up with the http version, the Twitter cards do not display.

When we check a URL such as Voyager 1 (one that works with Twitter on HTTPS) using the Twitter validator we get the error: “INFO: Page fetched successfully … WARN: No metatags found”

When I hit the HTTP URL using Curl (with or without the Twitterbot agent) then the redirect looks fine to me. It’s a regular 301 HTTP response with a Location header.

I shared these malfunctioning URLs with Twitter support and they told me the following:

“So when I curl it I do indeed see a 301 and then get the response back on the redirect. And it works from the command line with the Twitterbot user-agent. But when I run it internally the crawler is seeing an “OK” status, with a statuscode of 400. It gets the content, but because the statuscode is 400, it ignores it. I am not sure why that would be happening. Something in Netlify config? I cannot explain it.”

Can you help me diagnose this 400 error that the Twitterbot appears to provoke from your builtin HTTPS redirects?

Thanks,
Matt.

Hey @mattb ,
This is a known issue with our prerendering service. I believe you’re running into the same thing that several folks over here are running to: Og/twitter previews not working

My understanding of the problem is that Twitterbot and other bots will follow one redirect, but not two… and if you start from http, then there’s a redirect to https and then another to the primary custom domain.

I’ve added this thread to our internal tracking issue on this so we can follow up with you if/when we ship a fix :passenger_ship: