Repository navigation
feat(preview): fetch Cloudflare-challenged pages via Worker - #47
Merged
Merged
Conversation
Wrangler deploys the Cloudflare Worker in cloudflare/unfurl/.
Some sites behind Cloudflare (e.g. Untappd) serve a "Just a moment"
challenge to requests from hosting providers, so previews built on
Fly failed with a 403 and the links were shown as broken, even though
they work in a browser. Requests made from a Cloudflare Worker get
through.
- A 403 with cf-mitigated: challenge is now recognized as a challenge.
- On a challenge, the page is fetched again through an optional
unfurl worker (TUMBLE_UNFURL_WORKER_URL/_KEY), then archive.org.
- If all of that fails, the preview is {"blocked":"true"}: the front
page shows a plain link with no error badge, the link stays out of
the dead-link set, and it is retried daily.
The Worker lives in cloudflare/unfurl/ and requires a shared key.
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.
Problem
Links such as https://untappd.com/b/3-floyds-brewing-dark-lord-2026/6714073
showed as broken (403) on feed.stahnma.us but work in a browser.
Untappd is behind Cloudflare, which serves a "Just a moment" managed
challenge (
cf-mitigated: challenge) to requests from the Flymachine. Its IPv4 and IPv6 egress are both announced by AS396356
(Latitude.sh). The same Go client and user agents get a 200 from a
residential IP, and from a Cloudflare Worker.
Change
cf-mitigated: challengeis recognized as a challenge.unfurl worker, then archive.org as before.
{"blocked":"true"}. The frontpage shows a plain link with no error badge or card, the link is
not counted as dead, and it is retried daily.
cloudflare/unfurl/holds the Worker. It requires anX-Unfurl-Keyshared secret and only fetches http(s) URLs.
TUMBLE_UNFURL_WORKER_URLandTUMBLE_UNFURL_WORKER_KEY. When unset, behavior is unchangedexcept for the
blockedresponse.Testing
make testpasses, with new tests for the Worker success,challenged-again, bad-key and unconfigured paths.
og:title,og:image), 401 without the key, and 400 for non-http URLs.tumble2Fly app.