npm hono 3.2.4
v3.2.4

latest releases: 4.6.10, 4.6.9, 4.6.8...
17 months ago

"Small" Breaking Change

This release includes a "small" breaking change.

Before this release, if a HEAD request was received, the app would handle it with the handler defined in app.head(). If there were no preferred handlers, it would return "Not Found".

app.head('/foo', (c) => {
  return new Response(null, {
    headers: {
      Foo: 'Bar',
    },
  })
})

This would handle:

HEAD /foo

Since this release, app.head() will not be enabled. Instead, the app will automatically return the responses for HEAD requests if it has a preferred app.get() handler. This means you don't have to set the handlers for HEAD explicitly.

const app = new Hono()

app.get('/', (c) => {
  return c.text('Foo')
})

export default app
$ curl --head http://localhost:8787/
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8

If you want to customize the response for HEAD method, write like the following:

app.get('/', (c) => {
  if (c.req.method === 'HEAD') {
    return new Response(null, {
      headers: {
        'Content-Length': '12345',
      },
    })
  }
  return c.text('Foo')
})

You can still use app.head(), but it will not have any effect. So, you should remove them.

What's Changed

Full Changelog: v3.2.3...v3.2.4

Don't miss a new hono release

NewReleases is sending notifications on new releases.