Within the Nuxt context you can use useRequestEvent to access the incoming request.
// Get underlying request event
const event = useRequestEvent()
// Get the URL
const url = event?.path
In the browser, useRequestEvent will return undefined.
Parameters
This composable does not take any parameters.
Return Values
The h3 event object for the current request. Returns undefined on the client side.The URL path of the request.
Node.js request and response objects.
Type
export function useRequestEvent(): H3Event | undefined