RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Fixing SPA Link Previews with a Lambda in Front of AWS Amplify (and Why Rails Never H

Link preview crawlers don’t run JavaScript, so every route of a static SPA shares the same generic card. In Rails, a content_for :head block solves this per request. Without a server in the request path, you have to put one back.

Your SPA Shares as a Blank Card walks through putting a Lambda function URL behind Amplify rewrites to inject per-page Open Graph tags, the six bugs that kept the first version from working (rewrite order, silent API misses, an invalid image Content-Type, a square fallback image, duplicate tags, and UTC date shifts), and the lean handler that replaced it. It closes with a curl recipe for faking the crawlers and a checklist you can run against your own app.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in