Skip to main content

Function: applyHttpErrorHeaders()

applyHttpErrorHeaders(__namedParameters): void

Defined in: httpError.ts:137

Copies the headers a thrower attached to an error onto the response — the WWW-Authenticate header of a 401, above all.

Call it from a catch-all error middleware alongside toHttpError: without this half the status is right but MCP discovery is still broken, because the header that names the authorization server never reaches the client. Non-string header values are ignored; a value that is not an error object, or an error without headers, is a no-op.

Parameters

ParameterTypeDescription
__namedParameters{ ctx: Context; error: unknown; }-
__namedParameters.ctxContextThe Koa context whose response headers are being written.
__namedParameters.errorunknownThe caught value, of unknown shape.

Returns

void