next-api-decorators
next-api-decorators copied to clipboard
Cannot create API route containing "pages" in the path
Hey!
I am trying to create an API route to handle all requests from an admin to modify the pages of the public website. Base requests will be made at '/api/admin/pages', as you can see in the file structure below.
However, when I try this, I come across a 404 Cannot GET error. It's as if next-api-decorators recognizes the path, but that no GET endpoint was defined, which is not the case as you can see above.
After some further testing, I observed that it's specific to the endpoint containing "pages" in the path. Everything else seems to work (tried "p", "pa", "pag", "page" or any other random set of characters) as the route is found and the intended data is returned, but as soon as i put it back to "pages" it returns this error.
Is it a known bug/behaviour?
(I imagine it might be a regex issue to avoid conflicts with the Next.js "pages" directory, or something like that?)
How to reproduce
- Create a Next.js app with next-api-decorators
- Create an endpoint that would return basic data as shown above "api/admin/pages" (GET /)
- See the error
- Change the endpoint to anything else
- Observe that the expected data is returned
I looked around and didn't find any issue related to this one, so I hope it's not a duplicate. I didn't find any reference to this in the documentation either.