NuxtN
Nuxt10mo ago
5 replies
jamzy

Nitro URL template

Hi all

Is there a way to fetch the URL template from within a nitro event handler?

For example, say I have some file /api/book/[id].get.ts.

If I fetch /api/book/123, how can some middleware display to me that it was this dynamic route that was hit.

The underlying reason is I want to log how often each endpoint is used. Part of this would be seeing each individual URL, which is straightforward. However I'd like to leverage the dynamic pattern too, so I can store that /api/book/123 uses the same handler as /api/book/456.

Thanks in advance if anyone knows
Was this page helpful?