I want to access my current route (eg /[user_id]/posts) for both regular pages and APIs, so that I can log it in errors, increase page hit counters, etc.
The only automated way I found to retrieve the current route involves useRouter, but that is only accessible in React components.
I want to avoid hardcoding a route in each of my handlers as that can get out of sync easily.
How can I automate retrieving the current route inside a handler?