Render directory screenshots with rasterly instead of Microlink - #562
Merged
Merged
Conversation
Microlink was the only screenshot provider for the directory's fetch-meta route. rasterly.dev is cheaper, so it becomes the primary renderer: one keyed GET returns the PNG bytes directly, with no second fetch to pull the image off a CDN. Microlink stays as a keyless fallback. RASTERLY_API_KEY is optional and the free tier is 100 renders/month, so when the key is absent or a render fails the old path still captures the screenshot rather than the field going empty. The Supabase upload is unchanged; the two providers now only return bytes, and captureScreenshot owns the storage write. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ThreatCrush Security Scan45 finding(s) HIGH/CRITICAL: 1 | MEDIUM: 8 | LOW: 36
Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Swaps the directory's homepage screenshot provider from Microlink to rasterly.dev, which is cheaper.
What changed
src/app/api/directory/fetch-meta/route.ts—captureScreenshot()now asks rasterly first and falls back to Microlink:renderWithRasterly()—GET /v1/screenshot?url=…&format=png&width=1280&height=800with the key in anX-Api-Keyheader. The response body is the PNG, so the old two-hop dance (JSON → CDN URL → second fetch) is gone on the happy path.renderWithMicrolink()— the previous logic, unchanged, kept as a keyless fallback.captureScreenshot()now owns the Supabase upload; the providers only return bytes. The storage write, themd5(url)/timestamp.pngpath and the memoised service client are all untouched.The fallback is deliberate:
RASTERLY_API_KEYis optional and the free tier is 100 renders/month, so a missing key or a failed render still produces a screenshot rather than an empty field.Config
RASTERLY_API_KEYis already set on theugig.netRailway service (production, set with--skip-deploys) and stored in theugig-net--prodteam vault. Added to.env.example.Verification
pnpm type-checkclean,eslinton the changed route exits 0pnpm test:run— 2134 tests / 222 files passhttps://ugig.net→ 106,058-byte PNG,https://profullstack.com→ 78,265-byte PNG, both1280x800, quota header decrementing as expectednull, so the Microlink fallback runs🤖 Generated with Claude Code