How a request is served
How a request is served in the Dusk guide.
Choose a route and follow it through middleware, a loader and the response.
createHandler returns an object with one method, fetch(request). The dev server, production adapters and
prerendering all call this handler, so the same request checks apply to each. In order, and each step only if the earlier ones
accepted the request:
- Guards: URL longer than 8192 characters (414), unknown method (405), a
Hostthat is not inallowedHosts(400), contradictory body framing (400), a declared body over 1 MiB (413). - Resolution: the health path, a server function (
/_dusk/fn/<id>), an API route, or a page. - CSRF for every method except
GET,HEADandOPTIONS(403). - Middleware from
entry-server.ts, outermost first.await next()resolves with the response the client will get, also when the route threw (see Middleware). - The route: the server function, the API handler, or the page (loaders run first, then the app renders and streams).
- Response headers: cookies you set, secure headers, CSP for HTML,
cache-control: private, no-storeunless the route set one,x-request-id.
The request is also raced against a 30 second budget (504) and a body limit that applies while the body is read.
createHandler lists every option; Security
covers the checks.