Skip to content

Conversation

@rossipedia
Copy link
Contributor

Per the HTTPWG spec:

The HEAD method is identical to GET except that the server MUST NOT send content in the response. HEAD is used to obtain metadata about the selected representation without transferring its representation data, often for the sake of testing hypertext links or finding recent modifications.

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2025

🦋 Changeset detected

Latest commit: 3e6e7e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@react-router/dev Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch
react-router Patch
react-router-dom Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch

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

@rossipedia rossipedia changed the title Merge branch 'release-next' into dev Return empty Response body for HEAD requests in default server entry Oct 31, 2025
@MichaelDeBoey MichaelDeBoey changed the title Return empty Response body for HEAD requests in default server entry fix(dev/config/defaults): return empty Response body for HEAD requests Oct 31, 2025
@brophdawg11
Copy link
Contributor

Just adding some context from our convo in discord that led to this PR for future visibility.

The initial concern with skipping the render is that if the render were to throw it would result in a 500 status, so if we short circuit it and send a 200 we might be incorrect. The spec doesn't specifically address status code but it does talk about this situation when it comes to header and indicated it's fine to have minor inconsistencies instead of generating and discarding the content. This feels like it naturally applies to status code as well - and in the vast majority of cases we should have a correct status code after loaders/actions run.

Spec text (emphasis ours):

The server SHOULD send the same header fields in response to a HEAD request as it would have sent if the request method had been GET. However, a server MAY omit header fields for which a value is determined only while generating the content. For example, some servers buffer a dynamic response to GET until a minimum amount of data is generated so that they can more efficiently delimit small responses or make late decisions with regard to content selection. Such a response to GET might contain Content-Length and Vary fields, for example, that are not generated within a HEAD response. These minor inconsistencies are considered preferable to generating and discarding the content for a HEAD request, since HEAD is usually requested for the sake of efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants