Body limits — Middleware · Hono

Refuse a request body before a handler reads it: a JSON limit with a message of your own, and a raw upload limit with the middleware’s default 413.

What you will learn

Read the theory for Body limits

All Middleware lessons

All Hono courses

loading types…

What you'll learn

  • Put bodyLimit({ maxSize }) in front of a route and see the 413 Payload Too Large it answers by default
  • Replace the refusal with onError, so the API’s errors keep one shape
  • Know what the limit measures: bytes on the wire, from Content-Length when present and from the stream otherwise