Next.js Discord

Discord Forum

How to run code after requests in Next.js (to perform canonical logging and to flush logs)

Unanswered
Orinoco Crocodile posted this in #help-forum
Open in Discord
Orinoco CrocodileOP
I want to log all requests to API endpoints, while adding some context while the endpoint is executing, eg (user_id=abcd123, api_key=id_asdf)

Tried middleware, but it doesn't run after the requests has finished running, so the canonical context is missing.

0 Replies