Install using bunx shadcn@latest add @remix-utils/middleware-request-id.
The Request ID middleware generates a unique ID for each request and stores it in the Router context, this can be useful to log the request and response information and correlate them.
Install using
bunx shadcn@latest add @remix-utils/middleware-request-id.The Request ID middleware generates a unique ID for each request and stores it in the Router context, this can be useful to log the request and response information and correlate them.
To use it, you need to add it to the
middlewarearray in yourapp/root.tsxfile.And you can use the
getRequestIDfunction in your loaders, actions, and other middleware to get the request ID.By default the request ID is a UUID, but you can customize it by passing a function to the
createRequestIDMiddlewarefunction.The middleware also gets the request ID from the
X-Request-IDheader if it's present, this can be useful to correlate requests between services.If you want to use a different header you can pass the header name to the
createRequestIDMiddlewarefunction.You can disable this behaviour by passing
nullinstead.Author
Sergio XalambrÃ