Documentation
Docs
Introduction
Getting Started
Tutorial: build an app
Core Concepts
Routing
Server-Side Rendering
Mimir, state management
Pages & Layouts
API Routes
Styling & Theming
Building & Deploying
API Reference
Guides
Recipes
FAQ (use cases)
requestId()
Give every request a stable id so you can correlate log lines, across the request and across services.
Use case
When something goes wrong in production, you need to follow a single request through every log line it
produced. A request id is that thread: attach it to each log, return it to the client, and a support ticket
("error, id abc123") points straight at the relevant logs.
How it works
It reuses an incoming X-Request-Id header if present (so an id set by your proxy or an upstream service
carries through), otherwise it generates a UUID. It sets req.id for your handlers and echoes the id back in
the X-Request-Id response header. Then it calls next(). There are no options.
Configuration
No options. Register it first, so every subsequent middleware, handler, and error can include req.id.
Example
Notes
Put
requestIdat (or near) the top of the chain, aboveerrorHandleris fine since the id is set onreqimmediately, so the error log can reference it. Passreq.idinto any downstream service call to extend the trace across process boundaries.
Next: timeout.