Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/transport-commons/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export function getServiceMethod(_httpMethod: string, id: unknown, headerOverrid
return mappedMethod
}

if (httpMethod === 'get') {
// HEAD is semantically a GET without a body (RFC 9110). Map it the same
// way so Express/Koa REST endpoints do not 405/500 on HEAD probes.
if (httpMethod === 'get' || httpMethod === 'head') {
return id === null ? 'find' : 'get'
}

Expand Down
3 changes: 3 additions & 0 deletions packages/transport-commons/test/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ describe('@feathersjs/transport-commons HTTP helpers', () => {
it('getServiceMethod', () => {
assert.strictEqual(http.getServiceMethod('GET', 2), 'get')
assert.strictEqual(http.getServiceMethod('GET', null), 'find')
assert.strictEqual(http.getServiceMethod('HEAD', 2), 'get')
assert.strictEqual(http.getServiceMethod('HEAD', null), 'find')
assert.strictEqual(http.getServiceMethod('head', null), 'find')
assert.strictEqual(http.getServiceMethod('PoST', null), 'create')
assert.strictEqual(http.getServiceMethod('PoST', null, 'customMethod'), 'customMethod')
assert.strictEqual(http.getServiceMethod('delete', null), 'remove')
Expand Down
Loading