feat: handle OPTIONS on /anything#162
Closed
cyfung1031 wants to merge 1 commit into
Closed
Conversation
/anything currently registers GET/POST/PUT/PATCH/DELETE but not OPTIONS, so an OPTIONS request to it 404s instead of being echoed back like every other method - unlike httpbin/httpbun, which commonly returns 200 for OPTIONS. This mirrors the precedent already set by the /b/:id bin-capture route, which explicitly registers OPTIONS alongside the other methods and runs it through the same handler rather than special-casing it as a bare CORS-style 204 - since "anything" is meant to accept anything, including a preflight-shaped request. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request adds support for the OPTIONS HTTP method on the /anything route, allowing it to be handled by the same echo handler as other methods. A corresponding test case has been added to verify that OPTIONS requests return a 200 status code and echo back the request details. No review comments were provided, so there is no feedback to address.
Author
|
Sorry for using Vibe Coding. In one of my projects (https://github.com/scriptscat/scriptcat/),
Hope you might consider to merge this PR for the API enhancement. |
This was referenced Jul 17, 2026
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.

Please check if the PR fulfills these requirements
What kind of change does this PR introduce? Feature —
/anythingnow handlesOPTIONSlike every other method instead of 404ing.Summary
/anythingcurrently registers GET/POST/PUT/PATCH/DELETE but not OPTIONS, so an OPTIONS request to it 404s instead of being echoed back like every other method:I ran into this migrating a project's GM_xmlhttpRequest test suite onto mockhttp.org — a test exercising
OPTIONSagainst/anything(the closest equivalent to httpbin/httpbun, which commonly return 200 for OPTIONS) got a 404 instead.Fix
Registers
fastify.options("/anything", ...)alongside the other methods, running through the exact same echo handler rather than special-casing it as a bare CORS-style 204. This mirrors the precedent already set by the/b/:idbin-capture route (src/routes/bins/capture.ts), which explicitly loops over["get", "post", "put", "patch", "delete", "options"]and treats OPTIONS as just another method to record and echo — since "anything" is meant to accept anything, including a preflight-shaped request.Test plan
OPTIONS /anythingreturns 200 withmethod: "OPTIONS"in the echoed body.pnpm test(lint + full vitest run with coverage) passes locally: 474 tests, 100% line coverage, no lint warnings.tsx src/index.tsinstance.