Repository navigation
fix: make photo search work on Cloudflare Workers - #8
Merged
Merged
Conversation
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.
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
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
"manual", and a 302 from Unsplash is refused without requesting its target