コンテンツにスキップ
日本語

ServerBuilder

このコンテンツはまだ日本語訳がありません。

Defined in: src/http/HttpExtension.ts:19

bind(routes): Promise<ServerBinding>

Defined in: src/http/HttpExtension.ts:51

Register the full route tree and bind. Returns the ServerBinding.

Route

Promise<ServerBinding>


useBackend(backend): ServerBuilder

Defined in: src/http/HttpExtension.ts:21

Override the default Fastify backend (or use Express / Hono).

HttpServerBackend

ServerBuilder


withErrorHandler(handler): ServerBuilder

Defined in: src/http/HttpExtension.ts:49

Last-resort handler for errors that escape every route-level handleErrors(...), plus backend-internal errors (body-parse failures, etc.). Overrides the framework’s default 500 mapping; if it throws, the default mapping still applies. Requires a backend that supports setErrorHandler (all shipped backends do).

(err, request) => HttpResponse | Promise<HttpResponse>

ServerBuilder


withSecurityHeaders(options): ServerBuilder

Defined in: src/http/HttpExtension.ts:41

Security response headers for this whole server, stamped by the backend onto every response it writes — including the error, not-found and WebSocket upgrade-reject paths that never flow back through a middleware, and the throw short-circuits that skip one.

Left alone, a server sends X-Content-Type-Options: nosniff and nothing else: it is the only header of the bundle that cannot change how an existing application is embedded, framed or referred to. Passing options opts into the full securityHeaders bundle — its own defaults included, so X-Frame-Options: DENY and Cross-Origin-Resource-Policy: same-origin come along and will break iframes and cross-origin embedding if that is how the app is used. false turns the mechanism off entirely.

A response’s own header always wins, whatever is configured here. Requires a backend that supports setDefaultResponseHeaders (all shipped backends do).

false | SecurityHeadersOptions

ServerBuilder