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