Skip to content

fix: make photo search work on Cloudflare Workers - #8

Merged
playlikeboy merged 1 commit into
mainfrom
fix/unsplash-fetch-on-workers
Nov 12, 2026
Merged

playlikeboy merged 1 commit into
mainfrom
fix/unsplash-fetch-on-workers

Conversation

@playlikeboy

Copy link
Copy Markdown
Owner

Problem

After PR #7 was deployed, the Photos tab on production returned "Photo search is temporarily unavailable" for every search. The Worker log showed Unsplash request failed: TypeError.

Cause

The Unsplash request passed redirect: "error". Cloudflare Workers reject that option with a TypeError; Node and Bun accept it, so local tests and CI passed.

Fix

Use redirect: "manual". A redirect is returned as a non-OK response and treated as an upstream failure, so the request still never follows one.

Test plan

  • 545 unit tests, including two new ones: the option is pinned to "manual", and a 302 from Unsplash is refused without requesting its target
  • Typecheck and lint
  • After deploy: search and insert a photo on production

The Unsplash request used redirect "error" so a redirect could never be
followed. Cloudflare Workers throw a TypeError for that option, so on
production every search failed with "temporarily unavailable" while it
passed under Node and Bun. It now uses redirect "manual": a redirect
comes back as a non-OK response and is refused the same way.

Tests pin the option and prove a redirect is never followed.
@playlikeboy
playlikeboy merged commit 7efce88 into main Nov 12, 2026
1 check passed
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