Skip to content

fix(next): support HEAD requests in REST routes#16761

Open
raunak3208 wants to merge 1 commit into
payloadcms:mainfrom
raunak3208:fix-head-media-route
Open

fix(next): support HEAD requests in REST routes#16761
raunak3208 wants to merge 1 commit into
payloadcms:mainfrom
raunak3208:fix-head-media-route

Conversation

@raunak3208
Copy link
Copy Markdown

What?

Adds explicit HEAD support to the Next.js REST route handlers by exporting:

export const HEAD = GET

from packages/next/src/routes/rest/index.ts.

Why?

/api/media/file/* routes were returning 404 for HEAD requests while returning 200 for the same resource with GET.

This causes inconsistent behavior for clients and proxies using HEAD requests for lightweight existence checks and does not align with RFC 9110 §9.3.2 behavior expectations.

How?

The REST route handlers already export GET, POST, PATCH, etc., but did not explicitly export a HEAD handler.

This PR maps HEAD to the existing GET handler so that HEAD requests follow the same routing and response logic without returning a response body.

Fixes #16754

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST: /api/media/file/* returns 404 on HEAD but 200 on GET (RFC 9110 §9.3.2 violation)

1 participant