-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: default head requests for endpoints when no explicit head method… #13210
Conversation
🦋 Changeset detectedLatest commit: 3709bf9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #13210 will not alter performanceComparing Summary
|
I think the idea of automatically enabling |
67a58dc
to
5d2395f
Compare
@ascorbic originally I've thought about saving time on the executing the GET handler, but, perhaps, you are right - according to spec we should aim to return the same status && headers, and we can do that only by executing the GET itself. I've updated the PR, wdyt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
Updated the changeset and added a line to the docs: withastro/docs#10947 |
Co-authored-by: Reuben Tier <[email protected]>
… implemented
Changes
I've noticed that
/_image
endpoint doesn't respond nicely (non 404) toHEAD
requests. After investigation, I've found that none of server endpoints respond to theHEAD
- they respond as 404.User must explicitly implement
export const HEAD
to add support for this endpoint or provideexport const ALL
.But typically users won't be doing this, since they typically might want just to add some
GET
handler and thats it. SinceHEAD
endpoint is useful for various things, for instance, checking if there is a route there but not caring about it's response - this PR adds default HEAD implementation for such cases.export const HEAD
export const GET
handler -HEAD
won't be auto-provided as wellALL
->HEAD
won't be auto-providedTesting
examples/ssr/
vianpm run dev
:2.1.
fetch('http://localhost:4321/api/products')
-> 200 (API endpoint)2.2.
fetch('http://localhost:4321/api/products', { method: 'HEAD' })
-> before 404, after 2002.3.
fetch('http://localhost:4321/products/2', { method: 'HEAD' })
-> before 200, after 200 (Page endpoint, not affected)Docs
Not sure about if docs should be updated.
Personally I'd expect this to work outside the box.