Getting Nuxt page (URL/Name) in API server request?
Hi All
I'm having trouble getting the nuxt component/page full path dynamically in my API eventhandler, without having to pass it as some sort of data in the request.
I've tried checking all the composables, but the one that works for me in middleware doesn't work in the API server:
useRequestURL();
Any ideas?3 Replies
More info: The error i get while trying to
useRequestUrl
, is: 'Vue app aliases are not allowed in server runtime.'do you mean the params?
Let say i have page: pages/abc.vue, that requests nuxt API server: /api/def
In def eventHandler i want to know what page requested the API, but i can at most only get origin: localhost:4200
The href for the event, is also only the api endpoint
I want the page origin URL path
Is it not possible to set some context on the event.context in the eventHandler ?
I see this as the least worse idea ATM
Just seems like something that should be easily done
I'm trying to do a pseudo CMS, so i need to validate the page url. Which is why i dont want to do it in query/body