N
Nuxt9mo ago
rxsto

Dynamic server routes not working

I'm trying to get the displayed route structure working in my server/api directory, but nuxt (or in this case nitro) seems to be unable to resolve routes with multiple dynamic parameters.
WARN [Vue Router warn]: No match found for location with path "/api/projects/5/apps"
WARN [Vue Router warn]: No match found for location with path "/api/projects/5/apps"
I have found an issue talking about this problem on GitHub (https://github.com/nuxt/nuxt/issues/24040), and they seem to have found a solution for their use-case, but I am unsure if I could apply something similar. The docs (https://nuxt.com/docs/guide/directory-structure/server#server-routes) are mentioning this as well, but it's quite incomprehensible as to what exactly the limiting factors are. This sort of directory structure is working perfectly fine for routing pages, so I'm a tad confused as to why this wouldn't be working for server routes. I'd appreciate any sort of idea as for how to fix or workaround this issue. Reworking the directory structure might work as well, but seems disadvantageous, as the current structure would be the proper convention. Thanks!
GitHub
Issues · nuxt/nuxt
The Intuitive Vue Framework. Contribute to nuxt/nuxt development by creating an account on GitHub.
Nuxt
server/ · Nuxt Directory Structure
The server/ directory is used to register API and server handlers to your application.
No description
7 Replies
rxsto
rxstoOP9mo ago
Partially dynamic routes are seemingly not possible (https://github.com/nuxt/nuxt/discussions/20863) either as far as i can tell from this issue? So is the routing capability inside of the server/api folder limited to just one fully dynamic part in the path?
GitHub
Possible to have Partial Dynamic Server API Routes? · nuxt nuxt · D...
Hello, when using the server API you can create dynamic routes like so /server/api/[id].js However, it doesn't seem to be possible to make a partial dynamic route /server/api/dynamic-[id].js So...
rxsto
rxstoOP9mo ago
Alright, I now narrowed the issue down to both partially dynamic routes (which I fortunately don't need) and index routes, everything else seems to be working fine.
rxsto
rxstoOP9mo ago
This works.
No description
rxsto
rxstoOP9mo ago
This doesn't.
No description
rxsto
rxstoOP9mo ago
moving out the index route and naming it the same as the directory it was supposed to route to fixes this issue. Not entirely sure why this happens, it feels like this should not be the case.
Flo
Flo9mo ago
I haven't noticed any issues with that yet 😮 (same structure) Just tested: DELETE {{ baseUrl }}/projects/6b056a53-2f2a-4900-9fdb-f2b200071016/os/servers/97b90a69-9223-4783-af80-2561a4e2314c contains 3 dynamic parts, no issues. Same for GET {{ baseUrl }}/projects/6b056a53-2f2a-4900-9fdb-f2b200071016/os/servers (calling index in directory with dynamic name)
Flo
Flo9mo ago
No description
Want results from more Discord servers?
Add your server