Crook
Crook
NNuxt
Created by Crook on 1/12/2025 in #❓・help
Server api nested index.js file is not detected
Hello there, I am quite new with Nuxt and this is my first post here, so I apologise if anything is incorrect! I have done a lot of searching and tried a bunch of solutions suggested by chatGPT without success. I am working on a Nuxt server api, in which I am having a strange problem. Right now I am working on a route, with the following folder structure. server - api - projects - [id].js - index.js - [projectId] - pebbles - index.js This results in the following route for my requests: api/projects/:projectId/pebbles. In the index.js file I have written code for handling GET and POST requests to the route, and everything works wonderfully. Now I am however trying to add a new file to the pebbles directory, and whenever the file I add is alphabetically ordered BEFORE index.js, the previously working route is no longer being found. Initially this came up as I was trying to add a [pebbleId].js file to handle PUT and DELETE requests, but the same error came with names such as abc.js etc. I have both tried adding code for handling in the files as well as just adding completely empty .js files, with the same result. If I named the new file x.js (alphabetically after index.js), the firstly mentioned GET request works again. Have I fundamentally misunderstood something or is something strange going on here?
9 replies