Fix search param types, expose rate-limit headers, remove CORS-breaking User-Agent header - #58
Open
hanoak wants to merge 3 commits into
Open
Fix search param types, expose rate-limit headers, remove CORS-breaking User-Agent header#58hanoak wants to merge 3 commits into
hanoak wants to merge 3 commits into
Conversation
Author
|
Hi @dvandersluis @dorelljames @josephfarina @dvandersluis @gwenevieve @LarsFlieger I've fixed 3 open issues. I'm tagging all of you here. All the information about this PR is mentioned above. Looking forward to discuss and merge the PR. |
hanoak
force-pushed
the
fix/search-params-headers-cors
branch
from
August 19, 2026 11:16
ad79dbd to
ce25606
Compare
Author
|
Hi @dvandersluis @dorelljames @josephfarina @dvandersluis @gwenevieve @LarsFlieger |
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.
Summary
This PR fixes three open issues:
orientation,size,color, andlocalefilter params. Added aPhotoFilterParamstype and wired it intophotos.search.X-Ratelimit-*response headers.createFetchWrappernow attaches the rawHeadersobject as a non-enumerable.headersproperty on every successful response (including the object returned byphotos.random()), with return types updated via a newWithHeaderstype.User-Agent: Pexels/JavaScriptheader. Browsers treatUser-Agentas a forbidden/CORS-unsafe header; Chrome silently drops the override (which is why it appeared to work there), but Firefox and Safari fail the CORS preflight entirely, blocking every request from this library in those browsers.Testing
yarn buildpasses for all three changes; generated.d.tsoutput was inspected for correctness.masterdue to a pre-existing bug in themutateAllValuesToNulltest helper (it only nulls truthy values, so live data drift likeliked: false,description: "", orvideos_count: 0trips snapshot diffs). None of these three fixes introduce any new failures beyond that baseline.Notes for maintainers
User-Agentremoval was verified with Node'sfetch(noUser-Agentsent, request still succeeds), but Node doesn't perform CORS preflight, so the actual browser-side failure couldn't be reproduced locally. The fix follows directly from the root cause identified in Fails to query in Firefox due to CORS #45 and its linked Chromium bug report.response.ok) responses; a non-ok response still throws a bareErrorwithout headers attached. Happy to extend this in a follow-up if useful.Closes #56, #53, #45, #48