Skip to content

feat(preview): fetch Cloudflare-challenged pages via Worker - #47

Merged
stahnma merged 2 commits into
mainfrom
feat/unfurl-worker
Nov 22, 2026
Merged

stahnma merged 2 commits into
mainfrom
feat/unfurl-worker

Conversation

@stahnma

@stahnma stahnma commented Nov 22, 2026

Copy link
Copy Markdown
Member

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 Fly
machine. 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

  • A 403 with cf-mitigated: challenge is recognized as a challenge.
  • On a challenge, the page is fetched again through an optional
    unfurl worker, then archive.org as before.
  • If all of that fails, the preview is {"blocked":"true"}. The front
    page 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 an X-Unfurl-Key
    shared secret and only fetches http(s) URLs.
  • New optional config: TUMBLE_UNFURL_WORKER_URL and
    TUMBLE_UNFURL_WORKER_KEY. When unset, behavior is unchanged
    except for the blocked response.
  • README, OpenAPI spec, and the flox env (wrangler) are updated.

Testing

  • make test passes, with new tests for the Worker success,
    challenged-again, bad-key and unconfigured paths.
  • The deployed Worker returns Untappd's real page (og:title,
    og:image), 401 without the key, and 400 for non-http URLs.
  • The secrets are already set on the tumble2 Fly app.

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.
@stahnma
stahnma merged commit 69ce473 into main Nov 22, 2026
1 check passed
@stahnma
stahnma deleted the feat/unfurl-worker branch November 22, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant