NuxtN
Nuxt9mo ago
5 replies
nemunyan

server/api/[route].ts doesn't work with dynamic route

I use Nuxt3 with Laravel to separate frontend/backend.
I catch every GET api routes with server/api/[route].get.tsexcept auth routes.
However,when I use dynamic route such as /api/users/${id}, that route is considered as location in Nuxt3,not API route to Laravel.

Nuxt 3.15.4
vue latest
Laravel 12.1

Some test results here:
fetch /api/doesexist -> return json
fetch /api/doesnotexist -> return Laravel's fallback
fetch /api/doesexist/${variable} -> Nuxt's 404 error
Was this page helpful?